home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 4 / BBS in a Box - Macintosh - Volume IV (January 1992) (BBS in a Box).iso / Files / Word / E-G / EGREP15.CPT / egrep-1.5 / grep-src / grep.c < prev    next >
MacBinary  |  1991-10-20  |  37.8 KB  |  [TEXT/MPS ]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
10% dexvert Jesper Olsen Module (music/jesperOlsen) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Sun Oct 20 00:04:39 1991, modified Sun Oct 20 00:04:39 1991, creator 'MPS ', type ASCII, 38128 bytes "grep.c" , at 0x9570 344 bytes resource default (weak)
99% file data default
49% TrID Macintosh plain text (MacBinary) default
33% TrID TTComp archive compressed (bin-4K) default (weak)
16% TrID MacBinary 2 default (weak)
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MPS ]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 06 67 72 65 70 2e 63 | 00 00 00 00 00 00 00 00 |..grep.c|........|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 01 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 94 f0 00 | 00 01 58 a5 26 b0 d7 a5 |........|..X.&...|
|00000060| 26 b0 d7 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |&.......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 95 9d 00 00 |........|........|
|00000080| 2f 2a 20 20 54 68 69 73 | 20 66 69 6c 65 20 68 61 |/* This| file ha|
|00000090| 73 20 62 65 65 6e 20 63 | 68 61 6e 67 65 64 2d 2d |s been c|hanged--|
|000000a0| 20 69 74 20 69 73 20 6e | 6f 74 20 74 68 65 20 73 | it is n|ot the s|
|000000b0| 74 61 6e 64 61 72 64 20 | 46 53 46 20 76 65 72 73 |tandard |FSF vers|
|000000c0| 69 6f 6e 2e 0d 0d 20 20 | 20 20 20 20 20 20 20 20 |ion... | |
|000000d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 4f | | O|
|000000e0| 63 74 20 31 39 39 31 2e | 20 20 2a 2f 0d 0d 0d 2f |ct 1991.| */.../|
|000000f0| 2a 20 67 72 65 70 20 2d | 20 70 72 69 6e 74 20 6c |* grep -| print l|
|00000100| 69 6e 65 73 20 6d 61 74 | 63 68 69 6e 67 20 61 6e |ines mat|ching an|
|00000110| 20 65 78 74 65 6e 64 65 | 64 20 72 65 67 75 6c 61 | extende|d regula|
|00000120| 72 20 65 78 70 72 65 73 | 73 69 6f 6e 0d 20 20 20 |r expres|sion. |
|00000130| 43 6f 70 79 72 69 67 68 | 74 20 28 43 29 20 31 39 |Copyrigh|t (C) 19|
|00000140| 38 38 20 46 72 65 65 20 | 53 6f 66 74 77 61 72 65 |88 Free |Software|
|00000150| 20 46 6f 75 6e 64 61 74 | 69 6f 6e 2c 20 49 6e 63 | Foundat|ion, Inc|
|00000160| 2e 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.. | |
|00000170| 20 20 20 20 20 20 20 20 | 57 72 69 74 74 65 6e 20 | |Written |
|00000180| 4a 75 6e 65 2c 20 31 39 | 38 38 20 62 79 20 4d 69 |June, 19|88 by Mi|
|00000190| 6b 65 20 48 61 65 72 74 | 65 6c 0d 09 20 20 20 20 |ke Haert|el.. |
|000001a0| 20 20 20 20 20 20 20 20 | 20 20 42 4d 47 20 73 70 | | BMG sp|
|000001b0| 65 65 64 75 70 73 20 61 | 64 64 65 64 20 4a 75 6c |eedups a|dded Jul|
|000001c0| 79 2c 20 31 39 38 38 0d | 09 09 09 62 79 20 4a 61 |y, 1988.|...by Ja|
|000001d0| 6d 65 73 20 41 2e 20 57 | 6f 6f 64 73 20 61 6e 64 |mes A. W|oods and|
|000001e0| 20 41 72 74 68 75 72 20 | 44 61 76 69 64 20 4f 6c | Arthur |David Ol|
|000001f0| 73 6f 6e 0d 0d 09 09 20 | 20 20 20 20 20 20 4e 4f |son.... | NO|
|00000200| 20 57 41 52 52 41 4e 54 | 59 0d 0d 20 20 42 45 43 | WARRANT|Y.. BEC|
|00000210| 41 55 53 45 20 54 48 49 | 53 20 50 52 4f 47 52 41 |AUSE THI|S PROGRA|
|00000220| 4d 20 49 53 20 4c 49 43 | 45 4e 53 45 44 20 46 52 |M IS LIC|ENSED FR|
|00000230| 45 45 20 4f 46 20 43 48 | 41 52 47 45 2c 20 57 45 |EE OF CH|ARGE, WE|
|00000240| 20 50 52 4f 56 49 44 45 | 20 41 42 53 4f 4c 55 54 | PROVIDE| ABSOLUT|
|00000250| 45 4c 59 0d 4e 4f 20 57 | 41 52 52 41 4e 54 59 2c |ELY.NO W|ARRANTY,|
|00000260| 20 54 4f 20 54 48 45 20 | 45 58 54 45 4e 54 20 50 | TO THE |EXTENT P|
|00000270| 45 52 4d 49 54 54 45 44 | 20 42 59 20 41 50 50 4c |ERMITTED| BY APPL|
|00000280| 49 43 41 42 4c 45 20 53 | 54 41 54 45 20 4c 41 57 |ICABLE S|TATE LAW|
|00000290| 2e 20 20 45 58 43 45 50 | 54 0d 57 48 45 4e 20 4f |. EXCEP|T.WHEN O|
|000002a0| 54 48 45 52 57 49 53 45 | 20 53 54 41 54 45 44 20 |THERWISE| STATED |
|000002b0| 49 4e 20 57 52 49 54 49 | 4e 47 2c 20 46 52 45 45 |IN WRITI|NG, FREE|
|000002c0| 20 53 4f 46 54 57 41 52 | 45 20 46 4f 55 4e 44 41 | SOFTWAR|E FOUNDA|
|000002d0| 54 49 4f 4e 2c 20 49 4e | 43 2c 0d 52 49 43 48 41 |TION, IN|C,.RICHA|
|000002e0| 52 44 20 4d 2e 20 53 54 | 41 4c 4c 4d 41 4e 20 41 |RD M. ST|ALLMAN A|
|000002f0| 4e 44 2f 4f 52 20 4f 54 | 48 45 52 20 50 41 52 54 |ND/OR OT|HER PART|
|00000300| 49 45 53 20 50 52 4f 56 | 49 44 45 20 54 48 49 53 |IES PROV|IDE THIS|
|00000310| 20 50 52 4f 47 52 41 4d | 20 22 41 53 20 49 53 22 | PROGRAM| "AS IS"|
|00000320| 0d 57 49 54 48 4f 55 54 | 20 57 41 52 52 41 4e 54 |.WITHOUT| WARRANT|
|00000330| 59 20 4f 46 20 41 4e 59 | 20 4b 49 4e 44 2c 20 45 |Y OF ANY| KIND, E|
|00000340| 49 54 48 45 52 20 45 58 | 50 52 45 53 53 45 44 20 |ITHER EX|PRESSED |
|00000350| 4f 52 20 49 4d 50 4c 49 | 45 44 2c 20 49 4e 43 4c |OR IMPLI|ED, INCL|
|00000360| 55 44 49 4e 47 2c 0d 42 | 55 54 20 4e 4f 54 20 4c |UDING,.B|UT NOT L|
|00000370| 49 4d 49 54 45 44 20 54 | 4f 2c 20 54 48 45 20 49 |IMITED T|O, THE I|
|00000380| 4d 50 4c 49 45 44 20 57 | 41 52 52 41 4e 54 49 45 |MPLIED W|ARRANTIE|
|00000390| 53 20 4f 46 20 4d 45 52 | 43 48 41 4e 54 41 42 49 |S OF MER|CHANTABI|
|000003a0| 4c 49 54 59 20 41 4e 44 | 0d 46 49 54 4e 45 53 53 |LITY AND|.FITNESS|
|000003b0| 20 46 4f 52 20 41 20 50 | 41 52 54 49 43 55 4c 41 | FOR A P|ARTICULA|
|000003c0| 52 20 50 55 52 50 4f 53 | 45 2e 20 20 54 48 45 20 |R PURPOS|E. THE |
|000003d0| 45 4e 54 49 52 45 20 52 | 49 53 4b 20 41 53 20 54 |ENTIRE R|ISK AS T|
|000003e0| 4f 20 54 48 45 20 51 55 | 41 4c 49 54 59 0d 41 4e |O THE QU|ALITY.AN|
|000003f0| 44 20 50 45 52 46 4f 52 | 4d 41 4e 43 45 20 4f 46 |D PERFOR|MANCE OF|
|00000400| 20 54 48 45 20 50 52 4f | 47 52 41 4d 20 49 53 20 | THE PRO|GRAM IS |
|00000410| 57 49 54 48 20 59 4f 55 | 2e 20 20 53 48 4f 55 4c |WITH YOU|. SHOUL|
|00000420| 44 20 54 48 45 20 50 52 | 4f 47 52 41 4d 20 50 52 |D THE PR|OGRAM PR|
|00000430| 4f 56 45 0d 44 45 46 45 | 43 54 49 56 45 2c 20 59 |OVE.DEFE|CTIVE, Y|
|00000440| 4f 55 20 41 53 53 55 4d | 45 20 54 48 45 20 43 4f |OU ASSUM|E THE CO|
|00000450| 53 54 20 4f 46 20 41 4c | 4c 20 4e 45 43 45 53 53 |ST OF AL|L NECESS|
|00000460| 41 52 59 20 53 45 52 56 | 49 43 49 4e 47 2c 20 52 |ARY SERV|ICING, R|
|00000470| 45 50 41 49 52 20 4f 52 | 0d 43 4f 52 52 45 43 54 |EPAIR OR|.CORRECT|
|00000480| 49 4f 4e 2e 0d 0d 20 49 | 4e 20 4e 4f 20 45 56 45 |ION... I|N NO EVE|
|00000490| 4e 54 20 55 4e 4c 45 53 | 53 20 52 45 51 55 49 52 |NT UNLES|S REQUIR|
|000004a0| 45 44 20 42 59 20 41 50 | 50 4c 49 43 41 42 4c 45 |ED BY AP|PLICABLE|
|000004b0| 20 4c 41 57 20 57 49 4c | 4c 20 52 49 43 48 41 52 | LAW WIL|L RICHAR|
|000004c0| 44 20 4d 2e 0d 53 54 41 | 4c 4c 4d 41 4e 2c 20 54 |D M..STA|LLMAN, T|
|000004d0| 48 45 20 46 52 45 45 20 | 53 4f 46 54 57 41 52 45 |HE FREE |SOFTWARE|
|000004e0| 20 46 4f 55 4e 44 41 54 | 49 4f 4e 2c 20 49 4e 43 | FOUNDAT|ION, INC|
|000004f0| 2e 2c 20 41 4e 44 2f 4f | 52 20 41 4e 59 20 4f 54 |., AND/O|R ANY OT|
|00000500| 48 45 52 20 50 41 52 54 | 59 0d 57 48 4f 20 4d 41 |HER PART|Y.WHO MA|
|00000510| 59 20 4d 4f 44 49 46 59 | 20 41 4e 44 20 52 45 44 |Y MODIFY| AND RED|
|00000520| 49 53 54 52 49 42 55 54 | 45 20 54 48 49 53 20 50 |ISTRIBUT|E THIS P|
|00000530| 52 4f 47 52 41 4d 20 41 | 53 20 50 45 52 4d 49 54 |ROGRAM A|S PERMIT|
|00000540| 54 45 44 20 42 45 4c 4f | 57 2c 20 42 45 0d 4c 49 |TED BELO|W, BE.LI|
|00000550| 41 42 4c 45 20 54 4f 20 | 59 4f 55 20 46 4f 52 20 |ABLE TO |YOU FOR |
|00000560| 44 41 4d 41 47 45 53 2c | 20 49 4e 43 4c 55 44 49 |DAMAGES,| INCLUDI|
|00000570| 4e 47 20 41 4e 59 20 4c | 4f 53 54 20 50 52 4f 46 |NG ANY L|OST PROF|
|00000580| 49 54 53 2c 20 4c 4f 53 | 54 20 4d 4f 4e 49 45 53 |ITS, LOS|T MONIES|
|00000590| 2c 20 4f 52 0d 4f 54 48 | 45 52 20 53 50 45 43 49 |, OR.OTH|ER SPECI|
|000005a0| 41 4c 2c 20 49 4e 43 49 | 44 45 4e 54 41 4c 20 4f |AL, INCI|DENTAL O|
|000005b0| 52 20 43 4f 4e 53 45 51 | 55 45 4e 54 49 41 4c 20 |R CONSEQ|UENTIAL |
|000005c0| 44 41 4d 41 47 45 53 20 | 41 52 49 53 49 4e 47 20 |DAMAGES |ARISING |
|000005d0| 4f 55 54 20 4f 46 20 54 | 48 45 0d 55 53 45 20 4f |OUT OF T|HE.USE O|
|000005e0| 52 20 49 4e 41 42 49 4c | 49 54 59 20 54 4f 20 55 |R INABIL|ITY TO U|
|000005f0| 53 45 20 28 49 4e 43 4c | 55 44 49 4e 47 20 42 55 |SE (INCL|UDING BU|
|00000600| 54 20 4e 4f 54 20 4c 49 | 4d 49 54 45 44 20 54 4f |T NOT LI|MITED TO|
|00000610| 20 4c 4f 53 53 20 4f 46 | 20 44 41 54 41 20 4f 52 | LOSS OF| DATA OR|
|00000620| 0d 44 41 54 41 20 42 45 | 49 4e 47 20 52 45 4e 44 |.DATA BE|ING REND|
|00000630| 45 52 45 44 20 49 4e 41 | 43 43 55 52 41 54 45 20 |ERED INA|CCURATE |
|00000640| 4f 52 20 4c 4f 53 53 45 | 53 20 53 55 53 54 41 49 |OR LOSSE|S SUSTAI|
|00000650| 4e 45 44 20 42 59 20 54 | 48 49 52 44 20 50 41 52 |NED BY T|HIRD PAR|
|00000660| 54 49 45 53 20 4f 52 0d | 41 20 46 41 49 4c 55 52 |TIES OR.|A FAILUR|
|00000670| 45 20 4f 46 20 54 48 45 | 20 50 52 4f 47 52 41 4d |E OF THE| PROGRAM|
|00000680| 20 54 4f 20 4f 50 45 52 | 41 54 45 20 57 49 54 48 | TO OPER|ATE WITH|
|00000690| 20 41 4e 59 20 4f 54 48 | 45 52 20 50 52 4f 47 52 | ANY OTH|ER PROGR|
|000006a0| 41 4d 53 29 20 54 48 49 | 53 0d 50 52 4f 47 52 41 |AMS) THI|S.PROGRA|
|000006b0| 4d 2c 20 45 56 45 4e 20 | 49 46 20 59 4f 55 20 48 |M, EVEN |IF YOU H|
|000006c0| 41 56 45 20 42 45 45 4e | 20 41 44 56 49 53 45 44 |AVE BEEN| ADVISED|
|000006d0| 20 4f 46 20 54 48 45 20 | 50 4f 53 53 49 42 49 4c | OF THE |POSSIBIL|
|000006e0| 49 54 59 20 4f 46 20 53 | 55 43 48 0d 44 41 4d 41 |ITY OF S|UCH.DAMA|
|000006f0| 47 45 53 2c 20 4f 52 20 | 46 4f 52 20 41 4e 59 20 |GES, OR |FOR ANY |
|00000700| 43 4c 41 49 4d 20 42 59 | 20 41 4e 59 20 4f 54 48 |CLAIM BY| ANY OTH|
|00000710| 45 52 20 50 41 52 54 59 | 2e 0d 0d 09 09 47 45 4e |ER PARTY|.....GEN|
|00000720| 45 52 41 4c 20 50 55 42 | 4c 49 43 20 4c 49 43 45 |ERAL PUB|LIC LICE|
|00000730| 4e 53 45 20 54 4f 20 43 | 4f 50 59 0d 0d 20 20 31 |NSE TO C|OPY.. 1|
|00000740| 2e 20 59 6f 75 20 6d 61 | 79 20 63 6f 70 79 20 61 |. You ma|y copy a|
|00000750| 6e 64 20 64 69 73 74 72 | 69 62 75 74 65 20 76 65 |nd distr|ibute ve|
|00000760| 72 62 61 74 69 6d 20 63 | 6f 70 69 65 73 20 6f 66 |rbatim c|opies of|
|00000770| 20 74 68 69 73 20 73 6f | 75 72 63 65 20 66 69 6c | this so|urce fil|
|00000780| 65 0d 61 73 20 79 6f 75 | 20 72 65 63 65 69 76 65 |e.as you| receive|
|00000790| 20 69 74 2c 20 69 6e 20 | 61 6e 79 20 6d 65 64 69 | it, in |any medi|
|000007a0| 75 6d 2c 20 70 72 6f 76 | 69 64 65 64 20 74 68 61 |um, prov|ided tha|
|000007b0| 74 20 79 6f 75 20 63 6f | 6e 73 70 69 63 75 6f 75 |t you co|nspicuou|
|000007c0| 73 6c 79 20 61 6e 64 0d | 61 70 70 72 6f 70 72 69 |sly and.|appropri|
|000007d0| 61 74 65 6c 79 20 70 75 | 62 6c 69 73 68 20 6f 6e |ately pu|blish on|
|000007e0| 20 65 61 63 68 20 63 6f | 70 79 20 61 20 76 61 6c | each co|py a val|
|000007f0| 69 64 20 63 6f 70 79 72 | 69 67 68 74 20 6e 6f 74 |id copyr|ight not|
|00000800| 69 63 65 20 22 43 6f 70 | 79 72 69 67 68 74 0d 20 |ice "Cop|yright. |
|00000810| 28 43 29 20 31 39 38 38 | 20 46 72 65 65 20 53 6f |(C) 1988| Free So|
|00000820| 66 74 77 61 72 65 20 46 | 6f 75 6e 64 61 74 69 6f |ftware F|oundatio|
|00000830| 6e 2c 20 49 6e 63 2e 22 | 3b 20 61 6e 64 20 69 6e |n, Inc."|; and in|
|00000840| 63 6c 75 64 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |clude fo|llowing |
|00000850| 74 68 65 0d 63 6f 70 79 | 72 69 67 68 74 20 6e 6f |the.copy|right no|
|00000860| 74 69 63 65 20 61 20 76 | 65 72 62 61 74 69 6d 20 |tice a v|erbatim |
|00000870| 63 6f 70 79 20 6f 66 20 | 74 68 65 20 61 62 6f 76 |copy of |the abov|
|00000880| 65 20 64 69 73 63 6c 61 | 69 6d 65 72 20 6f 66 20 |e discla|imer of |
|00000890| 77 61 72 72 61 6e 74 79 | 0d 61 6e 64 20 6f 66 20 |warranty|.and of |
|000008a0| 74 68 69 73 20 4c 69 63 | 65 6e 73 65 2e 20 20 59 |this Lic|ense. Y|
|000008b0| 6f 75 20 6d 61 79 20 63 | 68 61 72 67 65 20 61 20 |ou may c|harge a |
|000008c0| 64 69 73 74 72 69 62 75 | 74 69 6f 6e 20 66 65 65 |distribu|tion fee|
|000008d0| 20 66 6f 72 20 74 68 65 | 0d 70 68 79 73 69 63 61 | for the|.physica|
|000008e0| 6c 20 61 63 74 20 6f 66 | 20 74 72 61 6e 73 66 65 |l act of| transfe|
|000008f0| 72 72 69 6e 67 20 61 20 | 63 6f 70 79 2e 0d 0d 20 |rring a |copy... |
|00000900| 20 32 2e 20 59 6f 75 20 | 6d 61 79 20 6d 6f 64 69 | 2. You |may modi|
|00000910| 66 79 20 79 6f 75 72 20 | 63 6f 70 79 20 6f 72 20 |fy your |copy or |
|00000920| 63 6f 70 69 65 73 20 6f | 66 20 74 68 69 73 20 73 |copies o|f this s|
|00000930| 6f 75 72 63 65 20 66 69 | 6c 65 20 6f 72 0d 61 6e |ource fi|le or.an|
|00000940| 79 20 70 6f 72 74 69 6f | 6e 20 6f 66 20 69 74 2c |y portio|n of it,|
|00000950| 20 61 6e 64 20 63 6f 70 | 79 20 61 6e 64 20 64 69 | and cop|y and di|
|00000960| 73 74 72 69 62 75 74 65 | 20 73 75 63 68 20 6d 6f |stribute| such mo|
|00000970| 64 69 66 69 63 61 74 69 | 6f 6e 73 20 75 6e 64 65 |dificati|ons unde|
|00000980| 72 0d 74 68 65 20 74 65 | 72 6d 73 20 6f 66 20 50 |r.the te|rms of P|
|00000990| 61 72 61 67 72 61 70 68 | 20 31 20 61 62 6f 76 65 |aragraph| 1 above|
|000009a0| 2c 20 70 72 6f 76 69 64 | 65 64 20 74 68 61 74 20 |, provid|ed that |
|000009b0| 79 6f 75 20 61 6c 73 6f | 20 64 6f 20 74 68 65 20 |you also| do the |
|000009c0| 66 6f 6c 6c 6f 77 69 6e | 67 3a 0d 0d 20 20 20 20 |followin|g:.. |
|000009d0| 61 29 20 63 61 75 73 65 | 20 74 68 65 20 6d 6f 64 |a) cause| the mod|
|000009e0| 69 66 69 65 64 20 66 69 | 6c 65 73 20 74 6f 20 63 |ified fi|les to c|
|000009f0| 61 72 72 79 20 70 72 6f | 6d 69 6e 65 6e 74 20 6e |arry pro|minent n|
|00000a00| 6f 74 69 63 65 73 20 73 | 74 61 74 69 6e 67 0d 20 |otices s|tating. |
|00000a10| 20 20 20 74 68 61 74 20 | 79 6f 75 20 63 68 61 6e | that |you chan|
|00000a20| 67 65 64 20 74 68 65 20 | 66 69 6c 65 73 20 61 6e |ged the |files an|
|00000a30| 64 20 74 68 65 20 64 61 | 74 65 20 6f 66 20 61 6e |d the da|te of an|
|00000a40| 79 20 63 68 61 6e 67 65 | 3b 20 61 6e 64 0d 0d 20 |y change|; and.. |
|00000a50| 20 20 20 62 29 20 63 61 | 75 73 65 20 74 68 65 20 | b) ca|use the |
|00000a60| 77 68 6f 6c 65 20 6f 66 | 20 61 6e 79 20 77 6f 72 |whole of| any wor|
|00000a70| 6b 20 74 68 61 74 20 79 | 6f 75 20 64 69 73 74 72 |k that y|ou distr|
|00000a80| 69 62 75 74 65 20 6f 72 | 20 70 75 62 6c 69 73 68 |ibute or| publish|
|00000a90| 2c 0d 20 20 20 20 74 68 | 61 74 20 69 6e 20 77 68 |,. th|at in wh|
|00000aa0| 6f 6c 65 20 6f 72 20 69 | 6e 20 70 61 72 74 20 63 |ole or i|n part c|
|00000ab0| 6f 6e 74 61 69 6e 73 20 | 6f 72 20 69 73 20 61 20 |ontains |or is a |
|00000ac0| 64 65 72 69 76 61 74 69 | 76 65 20 6f 66 20 74 68 |derivati|ve of th|
|00000ad0| 69 73 0d 20 20 20 20 70 | 72 6f 67 72 61 6d 20 6f |is. p|rogram o|
|00000ae0| 72 20 61 6e 79 20 70 61 | 72 74 20 74 68 65 72 65 |r any pa|rt there|
|00000af0| 6f 66 2c 20 74 6f 20 62 | 65 20 6c 69 63 65 6e 73 |of, to b|e licens|
|00000b00| 65 64 20 61 74 20 6e 6f | 20 63 68 61 72 67 65 20 |ed at no| charge |
|00000b10| 74 6f 20 61 6c 6c 0d 20 | 20 20 20 74 68 69 72 64 |to all. | third|
|00000b20| 20 70 61 72 74 69 65 73 | 20 6f 6e 20 74 65 72 6d | parties| on term|
|00000b30| 73 20 69 64 65 6e 74 69 | 63 61 6c 20 74 6f 20 74 |s identi|cal to t|
|00000b40| 68 6f 73 65 20 63 6f 6e | 74 61 69 6e 65 64 20 69 |hose con|tained i|
|00000b50| 6e 20 74 68 69 73 0d 20 | 20 20 20 4c 69 63 65 6e |n this. | Licen|
|00000b60| 73 65 20 41 67 72 65 65 | 6d 65 6e 74 20 28 65 78 |se Agree|ment (ex|
|00000b70| 63 65 70 74 20 74 68 61 | 74 20 79 6f 75 20 6d 61 |cept tha|t you ma|
|00000b80| 79 20 63 68 6f 6f 73 65 | 20 74 6f 20 67 72 61 6e |y choose| to gran|
|00000b90| 74 20 6d 6f 72 65 20 65 | 78 74 65 6e 73 69 76 65 |t more e|xtensive|
|00000ba0| 0d 20 20 20 20 77 61 72 | 72 61 6e 74 79 20 70 72 |. war|ranty pr|
|00000bb0| 6f 74 65 63 74 69 6f 6e | 20 74 6f 20 73 6f 6d 65 |otection| to some|
|00000bc0| 20 6f 72 20 61 6c 6c 20 | 74 68 69 72 64 20 70 61 | or all |third pa|
|00000bd0| 72 74 69 65 73 2c 20 61 | 74 20 79 6f 75 72 20 6f |rties, a|t your o|
|00000be0| 70 74 69 6f 6e 29 2e 0d | 0d 20 20 20 20 63 29 20 |ption)..|. c) |
|00000bf0| 59 6f 75 20 6d 61 79 20 | 63 68 61 72 67 65 20 61 |You may |charge a|
|00000c00| 20 64 69 73 74 72 69 62 | 75 74 69 6f 6e 20 66 65 | distrib|ution fe|
|00000c10| 65 20 66 6f 72 20 74 68 | 65 20 70 68 79 73 69 63 |e for th|e physic|
|00000c20| 61 6c 20 61 63 74 20 6f | 66 0d 20 20 20 20 74 72 |al act o|f. tr|
|00000c30| 61 6e 73 66 65 72 72 69 | 6e 67 20 61 20 63 6f 70 |ansferri|ng a cop|
|00000c40| 79 2c 20 61 6e 64 20 79 | 6f 75 20 6d 61 79 20 61 |y, and y|ou may a|
|00000c50| 74 20 79 6f 75 72 20 6f | 70 74 69 6f 6e 20 6f 66 |t your o|ption of|
|00000c60| 66 65 72 20 77 61 72 72 | 61 6e 74 79 0d 20 20 20 |fer warr|anty. |
|00000c70| 20 70 72 6f 74 65 63 74 | 69 6f 6e 20 69 6e 20 65 | protect|ion in e|
|00000c80| 78 63 68 61 6e 67 65 20 | 66 6f 72 20 61 20 66 65 |xchange |for a fe|
|00000c90| 65 2e 0d 0d 4d 65 72 65 | 20 61 67 67 72 65 67 61 |e...Mere| aggrega|
|00000ca0| 74 69 6f 6e 20 6f 66 20 | 61 6e 6f 74 68 65 72 20 |tion of |another |
|00000cb0| 75 6e 72 65 6c 61 74 65 | 64 20 70 72 6f 67 72 61 |unrelate|d progra|
|00000cc0| 6d 20 77 69 74 68 20 74 | 68 69 73 20 70 72 6f 67 |m with t|his prog|
|00000cd0| 72 61 6d 20 28 6f 72 20 | 69 74 73 0d 64 65 72 69 |ram (or |its.deri|
|00000ce0| 76 61 74 69 76 65 29 20 | 6f 6e 20 61 20 76 6f 6c |vative) |on a vol|
|00000cf0| 75 6d 65 20 6f 66 20 61 | 20 73 74 6f 72 61 67 65 |ume of a| storage|
|00000d00| 20 6f 72 20 64 69 73 74 | 72 69 62 75 74 69 6f 6e | or dist|ribution|
|00000d10| 20 6d 65 64 69 75 6d 20 | 64 6f 65 73 20 6e 6f 74 | medium |does not|
|00000d20| 20 62 72 69 6e 67 0d 74 | 68 65 20 6f 74 68 65 72 | bring.t|he other|
|00000d30| 20 70 72 6f 67 72 61 6d | 20 75 6e 64 65 72 20 74 | program| under t|
|00000d40| 68 65 20 73 63 6f 70 65 | 20 6f 66 20 74 68 65 73 |he scope| of thes|
|00000d50| 65 20 74 65 72 6d 73 2e | 0d 0d 20 20 33 2e 20 59 |e terms.|.. 3. Y|
|00000d60| 6f 75 20 6d 61 79 20 63 | 6f 70 79 20 61 6e 64 20 |ou may c|opy and |
|00000d70| 64 69 73 74 72 69 62 75 | 74 65 20 74 68 69 73 20 |distribu|te this |
|00000d80| 70 72 6f 67 72 61 6d 20 | 6f 72 20 61 6e 79 20 70 |program |or any p|
|00000d90| 6f 72 74 69 6f 6e 20 6f | 66 20 69 74 20 69 6e 0d |ortion o|f it in.|
|00000da0| 63 6f 6d 70 69 6c 65 64 | 2c 20 65 78 65 63 75 74 |compiled|, execut|
|00000db0| 61 62 6c 65 20 6f 72 20 | 6f 62 6a 65 63 74 20 63 |able or |object c|
|00000dc0| 6f 64 65 20 66 6f 72 6d | 20 75 6e 64 65 72 20 74 |ode form| under t|
|00000dd0| 68 65 20 74 65 72 6d 73 | 20 6f 66 20 50 61 72 61 |he terms| of Para|
|00000de0| 67 72 61 70 68 73 0d 31 | 20 61 6e 64 20 32 20 61 |graphs.1| and 2 a|
|00000df0| 62 6f 76 65 20 70 72 6f | 76 69 64 65 64 20 74 68 |bove pro|vided th|
|00000e00| 61 74 20 79 6f 75 20 64 | 6f 20 74 68 65 20 66 6f |at you d|o the fo|
|00000e10| 6c 6c 6f 77 69 6e 67 3a | 0d 0d 20 20 20 20 61 29 |llowing:|.. a)|
|00000e20| 20 61 63 63 6f 6d 70 61 | 6e 79 20 69 74 20 77 69 | accompa|ny it wi|
|00000e30| 74 68 20 74 68 65 20 63 | 6f 6d 70 6c 65 74 65 20 |th the c|omplete |
|00000e40| 63 6f 72 72 65 73 70 6f | 6e 64 69 6e 67 20 6d 61 |correspo|nding ma|
|00000e50| 63 68 69 6e 65 2d 72 65 | 61 64 61 62 6c 65 0d 20 |chine-re|adable. |
|00000e60| 20 20 20 73 6f 75 72 63 | 65 20 63 6f 64 65 2c 20 | sourc|e code, |
|00000e70| 77 68 69 63 68 20 6d 75 | 73 74 20 62 65 20 64 69 |which mu|st be di|
|00000e80| 73 74 72 69 62 75 74 65 | 64 20 75 6e 64 65 72 20 |stribute|d under |
|00000e90| 74 68 65 20 74 65 72 6d | 73 20 6f 66 0d 20 20 20 |the term|s of. |
|00000ea0| 20 50 61 72 61 67 72 61 | 70 68 73 20 31 20 61 6e | Paragra|phs 1 an|
|00000eb0| 64 20 32 20 61 62 6f 76 | 65 3b 20 6f 72 2c 0d 0d |d 2 abov|e; or,..|
|00000ec0| 20 20 20 20 62 29 20 61 | 63 63 6f 6d 70 61 6e 79 | b) a|ccompany|
|00000ed0| 20 69 74 20 77 69 74 68 | 20 61 20 77 72 69 74 74 | it with| a writt|
|00000ee0| 65 6e 20 6f 66 66 65 72 | 2c 20 76 61 6c 69 64 20 |en offer|, valid |
|00000ef0| 66 6f 72 20 61 74 20 6c | 65 61 73 74 20 74 68 72 |for at l|east thr|
|00000f00| 65 65 0d 20 20 20 20 79 | 65 61 72 73 2c 20 74 6f |ee. y|ears, to|
|00000f10| 20 67 69 76 65 20 61 6e | 79 20 74 68 69 72 64 20 | give an|y third |
|00000f20| 70 61 72 74 79 20 66 72 | 65 65 20 28 65 78 63 65 |party fr|ee (exce|
|00000f30| 70 74 20 66 6f 72 20 61 | 20 6e 6f 6d 69 6e 61 6c |pt for a| nominal|
|00000f40| 0d 20 20 20 20 73 68 69 | 70 70 69 6e 67 20 63 68 |. shi|pping ch|
|00000f50| 61 72 67 65 29 20 61 20 | 63 6f 6d 70 6c 65 74 65 |arge) a |complete|
|00000f60| 20 6d 61 63 68 69 6e 65 | 2d 72 65 61 64 61 62 6c | machine|-readabl|
|00000f70| 65 20 63 6f 70 79 20 6f | 66 20 74 68 65 0d 20 20 |e copy o|f the. |
|00000f80| 20 20 63 6f 72 72 65 73 | 70 6f 6e 64 69 6e 67 20 | corres|ponding |
|00000f90| 73 6f 75 72 63 65 20 63 | 6f 64 65 2c 20 74 6f 20 |source c|ode, to |
|00000fa0| 62 65 20 64 69 73 74 72 | 69 62 75 74 65 64 20 75 |be distr|ibuted u|
|00000fb0| 6e 64 65 72 20 74 68 65 | 20 74 65 72 6d 73 20 6f |nder the| terms o|
|00000fc0| 66 0d 20 20 20 20 50 61 | 72 61 67 72 61 70 68 73 |f. Pa|ragraphs|
|00000fd0| 20 31 20 61 6e 64 20 32 | 20 61 62 6f 76 65 3b 20 | 1 and 2| above; |
|00000fe0| 6f 72 2c 0d 0d 20 20 20 | 20 63 29 20 61 63 63 6f |or,.. | c) acco|
|00000ff0| 6d 70 61 6e 79 20 69 74 | 20 77 69 74 68 20 74 68 |mpany it| with th|
|00001000| 65 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 79 6f |e inform|ation yo|
|00001010| 75 20 72 65 63 65 69 76 | 65 64 20 61 73 20 74 6f |u receiv|ed as to|
|00001020| 20 77 68 65 72 65 20 74 | 68 65 0d 20 20 20 20 63 | where t|he. c|
|00001030| 6f 72 72 65 73 70 6f 6e | 64 69 6e 67 20 73 6f 75 |orrespon|ding sou|
|00001040| 72 63 65 20 63 6f 64 65 | 20 6d 61 79 20 62 65 20 |rce code| may be |
|00001050| 6f 62 74 61 69 6e 65 64 | 2e 20 20 28 54 68 69 73 |obtained|. (This|
|00001060| 20 61 6c 74 65 72 6e 61 | 74 69 76 65 20 69 73 0d | alterna|tive is.|
|00001070| 20 20 20 20 61 6c 6c 6f | 77 65 64 20 6f 6e 6c 79 | allo|wed only|
|00001080| 20 66 6f 72 20 6e 6f 6e | 63 6f 6d 6d 65 72 63 69 | for non|commerci|
|00001090| 61 6c 20 64 69 73 74 72 | 69 62 75 74 69 6f 6e 20 |al distr|ibution |
|000010a0| 61 6e 64 20 6f 6e 6c 79 | 20 69 66 20 79 6f 75 0d |and only| if you.|
|000010b0| 20 20 20 20 72 65 63 65 | 69 76 65 64 20 74 68 65 | rece|ived the|
|000010c0| 20 70 72 6f 67 72 61 6d | 20 69 6e 20 6f 62 6a 65 | program| in obje|
|000010d0| 63 74 20 63 6f 64 65 20 | 6f 72 20 65 78 65 63 75 |ct code |or execu|
|000010e0| 74 61 62 6c 65 20 66 6f | 72 6d 20 61 6c 6f 6e 65 |table fo|rm alone|
|000010f0| 2e 29 0d 0d 46 6f 72 20 | 61 6e 20 65 78 65 63 75 |.)..For |an execu|
|00001100| 74 61 62 6c 65 20 66 69 | 6c 65 2c 20 63 6f 6d 70 |table fi|le, comp|
|00001110| 6c 65 74 65 20 73 6f 75 | 72 63 65 20 63 6f 64 65 |lete sou|rce code|
|00001120| 20 6d 65 61 6e 73 20 61 | 6c 6c 20 74 68 65 20 73 | means a|ll the s|
|00001130| 6f 75 72 63 65 20 63 6f | 64 65 20 66 6f 72 0d 61 |ource co|de for.a|
|00001140| 6c 6c 20 6d 6f 64 75 6c | 65 73 20 69 74 20 63 6f |ll modul|es it co|
|00001150| 6e 74 61 69 6e 73 3b 20 | 62 75 74 2c 20 61 73 20 |ntains; |but, as |
|00001160| 61 20 73 70 65 63 69 61 | 6c 20 65 78 63 65 70 74 |a specia|l except|
|00001170| 69 6f 6e 2c 20 69 74 20 | 6e 65 65 64 20 6e 6f 74 |ion, it |need not|
|00001180| 20 69 6e 63 6c 75 64 65 | 0d 73 6f 75 72 63 65 20 | include|.source |
|00001190| 63 6f 64 65 20 66 6f 72 | 20 6d 6f 64 75 6c 65 73 |code for| modules|
|000011a0| 20 77 68 69 63 68 20 61 | 72 65 20 73 74 61 6e 64 | which a|re stand|
|000011b0| 61 72 64 20 6c 69 62 72 | 61 72 69 65 73 20 74 68 |ard libr|aries th|
|000011c0| 61 74 20 61 63 63 6f 6d | 70 61 6e 79 20 74 68 65 |at accom|pany the|
|000011d0| 0d 6f 70 65 72 61 74 69 | 6e 67 20 73 79 73 74 65 |.operati|ng syste|
|000011e0| 6d 20 6f 6e 20 77 68 69 | 63 68 20 74 68 65 20 65 |m on whi|ch the e|
|000011f0| 78 65 63 75 74 61 62 6c | 65 20 66 69 6c 65 20 72 |xecutabl|e file r|
|00001200| 75 6e 73 2e 0d 0d 20 20 | 34 2e 20 59 6f 75 20 6d |uns... |4. You m|
|00001210| 61 79 20 6e 6f 74 20 63 | 6f 70 79 2c 20 73 75 62 |ay not c|opy, sub|
|00001220| 6c 69 63 65 6e 73 65 2c | 20 64 69 73 74 72 69 62 |license,| distrib|
|00001230| 75 74 65 20 6f 72 20 74 | 72 61 6e 73 66 65 72 20 |ute or t|ransfer |
|00001240| 74 68 69 73 20 70 72 6f | 67 72 61 6d 0d 65 78 63 |this pro|gram.exc|
|00001250| 65 70 74 20 61 73 20 65 | 78 70 72 65 73 73 6c 79 |ept as e|xpressly|
|00001260| 20 70 72 6f 76 69 64 65 | 64 20 75 6e 64 65 72 20 | provide|d under |
|00001270| 74 68 69 73 20 4c 69 63 | 65 6e 73 65 20 41 67 72 |this Lic|ense Agr|
|00001280| 65 65 6d 65 6e 74 2e 20 | 20 41 6e 79 20 61 74 74 |eement. | Any att|
|00001290| 65 6d 70 74 0d 6f 74 68 | 65 72 77 69 73 65 20 74 |empt.oth|erwise t|
|000012a0| 6f 20 63 6f 70 79 2c 20 | 73 75 62 6c 69 63 65 6e |o copy, |sublicen|
|000012b0| 73 65 2c 20 64 69 73 74 | 72 69 62 75 74 65 20 6f |se, dist|ribute o|
|000012c0| 72 20 74 72 61 6e 73 66 | 65 72 20 74 68 69 73 20 |r transf|er this |
|000012d0| 70 72 6f 67 72 61 6d 20 | 69 73 20 76 6f 69 64 20 |program |is void |
|000012e0| 61 6e 64 0d 79 6f 75 72 | 20 72 69 67 68 74 73 20 |and.your| rights |
|000012f0| 74 6f 20 75 73 65 20 74 | 68 65 20 70 72 6f 67 72 |to use t|he progr|
|00001300| 61 6d 20 75 6e 64 65 72 | 20 74 68 69 73 20 4c 69 |am under| this Li|
|00001310| 63 65 6e 73 65 20 61 67 | 72 65 65 6d 65 6e 74 20 |cense ag|reement |
|00001320| 73 68 61 6c 6c 20 62 65 | 0d 61 75 74 6f 6d 61 74 |shall be|.automat|
|00001330| 69 63 61 6c 6c 79 20 74 | 65 72 6d 69 6e 61 74 65 |ically t|erminate|
|00001340| 64 2e 20 20 48 6f 77 65 | 76 65 72 2c 20 70 61 72 |d. Howe|ver, par|
|00001350| 74 69 65 73 20 77 68 6f | 20 68 61 76 65 20 72 65 |ties who| have re|
|00001360| 63 65 69 76 65 64 20 63 | 6f 6d 70 75 74 65 72 0d |ceived c|omputer.|
|00001370| 73 6f 66 74 77 61 72 65 | 20 70 72 6f 67 72 61 6d |software| program|
|00001380| 73 20 66 72 6f 6d 20 79 | 6f 75 20 77 69 74 68 20 |s from y|ou with |
|00001390| 74 68 69 73 20 4c 69 63 | 65 6e 73 65 20 41 67 72 |this Lic|ense Agr|
|000013a0| 65 65 6d 65 6e 74 20 77 | 69 6c 6c 20 6e 6f 74 20 |eement w|ill not |
|000013b0| 68 61 76 65 0d 74 68 65 | 69 72 20 6c 69 63 65 6e |have.the|ir licen|
|000013c0| 73 65 73 20 74 65 72 6d | 69 6e 61 74 65 64 20 73 |ses term|inated s|
|000013d0| 6f 20 6c 6f 6e 67 20 61 | 73 20 73 75 63 68 20 70 |o long a|s such p|
|000013e0| 61 72 74 69 65 73 20 72 | 65 6d 61 69 6e 20 69 6e |arties r|emain in|
|000013f0| 20 66 75 6c 6c 20 63 6f | 6d 70 6c 69 61 6e 63 65 | full co|mpliance|
|00001400| 2e 0d 0d 20 20 35 2e 20 | 49 66 20 79 6f 75 20 77 |... 5. |If you w|
|00001410| 69 73 68 20 74 6f 20 69 | 6e 63 6f 72 70 6f 72 61 |ish to i|ncorpora|
|00001420| 74 65 20 70 61 72 74 73 | 20 6f 66 20 74 68 69 73 |te parts| of this|
|00001430| 20 70 72 6f 67 72 61 6d | 20 69 6e 74 6f 20 6f 74 | program| into ot|
|00001440| 68 65 72 20 66 72 65 65 | 0d 70 72 6f 67 72 61 6d |her free|.program|
|00001450| 73 20 77 68 6f 73 65 20 | 64 69 73 74 72 69 62 75 |s whose |distribu|
|00001460| 74 69 6f 6e 20 63 6f 6e | 64 69 74 69 6f 6e 73 20 |tion con|ditions |
|00001470| 61 72 65 20 64 69 66 66 | 65 72 65 6e 74 2c 20 77 |are diff|erent, w|
|00001480| 72 69 74 65 20 74 6f 20 | 74 68 65 20 46 72 65 65 |rite to |the Free|
|00001490| 0d 53 6f 66 74 77 61 72 | 65 20 46 6f 75 6e 64 61 |.Softwar|e Founda|
|000014a0| 74 69 6f 6e 20 61 74 20 | 36 37 35 20 4d 61 73 73 |tion at |675 Mass|
|000014b0| 20 41 76 65 2c 20 43 61 | 6d 62 72 69 64 67 65 2c | Ave, Ca|mbridge,|
|000014c0| 20 4d 41 20 30 32 31 33 | 39 2e 20 20 57 65 20 68 | MA 0213|9. We h|
|000014d0| 61 76 65 20 6e 6f 74 20 | 79 65 74 0d 77 6f 72 6b |ave not |yet.work|
|000014e0| 65 64 20 6f 75 74 20 61 | 20 73 69 6d 70 6c 65 20 |ed out a| simple |
|000014f0| 72 75 6c 65 20 74 68 61 | 74 20 63 61 6e 20 62 65 |rule tha|t can be|
|00001500| 20 73 74 61 74 65 64 20 | 68 65 72 65 2c 20 62 75 | stated |here, bu|
|00001510| 74 20 77 65 20 77 69 6c | 6c 20 6f 66 74 65 6e 20 |t we wil|l often |
|00001520| 70 65 72 6d 69 74 0d 74 | 68 69 73 2e 20 20 57 65 |permit.t|his. We|
|00001530| 20 77 69 6c 6c 20 62 65 | 20 67 75 69 64 65 64 20 | will be| guided |
|00001540| 62 79 20 74 68 65 20 74 | 77 6f 20 67 6f 61 6c 73 |by the t|wo goals|
|00001550| 20 6f 66 20 70 72 65 73 | 65 72 76 69 6e 67 20 74 | of pres|erving t|
|00001560| 68 65 20 66 72 65 65 20 | 73 74 61 74 75 73 20 6f |he free |status o|
|00001570| 66 0d 61 6c 6c 20 64 65 | 72 69 76 61 74 69 76 65 |f.all de|rivative|
|00001580| 73 20 6f 75 72 20 66 72 | 65 65 20 73 6f 66 74 77 |s our fr|ee softw|
|00001590| 61 72 65 20 61 6e 64 20 | 6f 66 20 70 72 6f 6d 6f |are and |of promo|
|000015a0| 74 69 6e 67 20 74 68 65 | 20 73 68 61 72 69 6e 67 |ting the| sharing|
|000015b0| 20 61 6e 64 20 72 65 75 | 73 65 20 6f 66 0d 73 6f | and reu|se of.so|
|000015c0| 66 74 77 61 72 65 2e 0d | 0d 0d 49 6e 20 6f 74 68 |ftware..|..In oth|
|000015d0| 65 72 20 77 6f 72 64 73 | 2c 20 79 6f 75 20 61 72 |er words|, you ar|
|000015e0| 65 20 77 65 6c 63 6f 6d | 65 20 74 6f 20 75 73 65 |e welcom|e to use|
|000015f0| 2c 20 73 68 61 72 65 20 | 61 6e 64 20 69 6d 70 72 |, share |and impr|
|00001600| 6f 76 65 20 74 68 69 73 | 20 70 72 6f 67 72 61 6d |ove this| program|
|00001610| 2e 0d 59 6f 75 20 61 72 | 65 20 66 6f 72 62 69 64 |..You ar|e forbid|
|00001620| 64 65 6e 20 74 6f 20 66 | 6f 72 62 69 64 20 61 6e |den to f|orbid an|
|00001630| 79 6f 6e 65 20 65 6c 73 | 65 20 74 6f 20 75 73 65 |yone els|e to use|
|00001640| 2c 20 73 68 61 72 65 20 | 61 6e 64 20 69 6d 70 72 |, share |and impr|
|00001650| 6f 76 65 0d 77 68 61 74 | 20 79 6f 75 20 67 69 76 |ove.what| you giv|
|00001660| 65 20 74 68 65 6d 2e 20 | 20 20 48 65 6c 70 20 73 |e them. | Help s|
|00001670| 74 61 6d 70 20 6f 75 74 | 20 73 6f 66 74 77 61 72 |tamp out| softwar|
|00001680| 65 2d 68 6f 61 72 64 69 | 6e 67 21 20 20 2a 2f 0d |e-hoardi|ng! */.|
|00001690| 0c 0d 23 69 6e 63 6c 75 | 64 65 20 3c 63 74 79 70 |..#inclu|de <ctyp|
|000016a0| 65 2e 68 3e 0d 23 69 6e | 63 6c 75 64 65 20 3c 73 |e.h>.#in|clude <s|
|000016b0| 74 64 69 6f 2e 68 3e 0d | 0d 23 69 6e 63 6c 75 64 |tdio.h>.|.#includ|
|000016c0| 65 20 3c 73 74 72 69 6e | 67 2e 68 3e 0d 23 69 6e |e <strin|g.h>.#in|
|000016d0| 63 6c 75 64 65 20 3c 73 | 74 64 6c 69 62 2e 68 3e |clude <s|tdlib.h>|
|000016e0| 0d 23 69 6e 63 6c 75 64 | 65 20 22 64 66 61 2e 68 |.#includ|e "dfa.h|
|000016f0| 22 0d 23 69 6e 63 6c 75 | 64 65 20 22 72 65 67 65 |".#inclu|de "rege|
|00001700| 78 2e 68 22 0d 23 69 6e | 63 6c 75 64 65 20 22 63 |x.h".#in|clude "c|
|00001710| 6f 6d 6d 6f 6e 2e 68 22 | 0d 0d 65 78 74 65 72 6e |ommon.h"|..extern|
|00001720| 20 65 72 72 6e 6f 3b 0d | 65 78 74 65 72 6e 20 63 | errno;.|extern c|
|00001730| 68 61 72 20 2a 73 79 73 | 5f 65 72 72 6c 69 73 74 |har *sys|_errlist|
|00001740| 5b 5d 3b 0d 0d 23 64 65 | 66 69 6e 65 20 4d 41 58 |[];..#de|fine MAX|
|00001750| 28 61 2c 20 62 29 20 28 | 28 61 29 20 3e 20 28 62 |(a, b) (|(a) > (b|
|00001760| 29 20 3f 20 28 61 29 20 | 3a 20 28 62 29 29 0d 0d |) ? (a) |: (b))..|
|00001770| 2f 2a 20 45 78 69 74 20 | 73 74 61 74 75 73 20 63 |/* Exit |status c|
|00001780| 6f 64 65 73 2e 20 2a 2f | 0d 23 64 65 66 69 6e 65 |odes. */|.#define|
|00001790| 20 4d 41 54 43 48 45 53 | 5f 46 4f 55 4e 44 20 30 | MATCHES|_FOUND 0|
|000017a0| 09 09 2f 2a 20 45 78 69 | 74 20 30 20 69 66 20 6e |../* Exi|t 0 if n|
|000017b0| 6f 20 65 72 72 6f 72 73 | 20 61 6e 64 20 6d 61 74 |o errors| and mat|
|000017c0| 63 68 65 73 20 66 6f 75 | 6e 64 2e 20 2a 2f 0d 23 |ches fou|nd. */.#|
|000017d0| 64 65 66 69 6e 65 20 4e | 4f 5f 4d 41 54 43 48 45 |define N|O_MATCHE|
|000017e0| 53 5f 46 4f 55 4e 44 20 | 31 09 2f 2a 20 45 78 69 |S_FOUND |1./* Exi|
|000017f0| 74 20 31 20 69 66 20 6e | 6f 20 6d 61 74 63 68 65 |t 1 if n|o matche|
|00001800| 73 20 77 65 72 65 20 66 | 6f 75 6e 64 2e 20 2a 2f |s were f|ound. */|
|00001810| 0d 23 64 65 66 69 6e 65 | 20 45 52 52 4f 52 20 32 |.#define| ERROR 2|
|00001820| 09 09 09 2f 2a 20 45 78 | 69 74 20 32 20 69 66 20 |.../* Ex|it 2 if |
|00001830| 73 6f 6d 65 20 65 72 72 | 6f 72 20 6f 63 63 75 72 |some err|or occur|
|00001840| 72 65 64 2e 20 2a 2f 0d | 0d 2f 2a 20 45 72 72 6f |red. */.|./* Erro|
|00001850| 72 20 69 73 20 73 65 74 | 20 74 72 75 65 20 69 66 |r is set| true if|
|00001860| 20 73 6f 6d 65 74 68 69 | 6e 67 20 61 77 66 75 6c | somethi|ng awful|
|00001870| 20 68 61 70 70 65 6e 65 | 64 2e 20 2a 2f 0d 73 74 | happene|d. */.st|
|00001880| 61 74 69 63 20 69 6e 74 | 20 65 72 72 6f 72 3b 0d |atic int| error;.|
|00001890| 0d 2f 2a 20 54 68 65 20 | 70 72 6f 67 72 61 6d 20 |./* The |program |
|000018a0| 6e 61 6d 65 20 66 6f 72 | 20 65 72 72 6f 72 20 6d |name for| error m|
|000018b0| 65 73 73 61 67 65 73 2e | 20 2a 2f 0d 73 74 61 74 |essages.| */.stat|
|000018c0| 69 63 20 63 68 61 72 20 | 2a 70 72 6f 67 3b 0d 76 |ic char |*prog;.v|
|000018d0| 6f 69 64 20 43 68 65 63 | 6b 46 6f 72 42 72 65 61 |oid Chec|kForBrea|
|000018e0| 6b 28 20 76 6f 69 64 20 | 29 3b 0d 0d 2f 2a 20 57 |k( void |);../* W|
|000018f0| 65 20 64 6f 20 61 6c 6c | 20 6f 75 72 20 6f 77 6e |e do all| our own|
|00001900| 20 62 75 66 66 65 72 69 | 6e 67 20 62 79 20 68 61 | bufferi|ng by ha|
|00001910| 6e 64 20 66 6f 72 20 65 | 66 66 69 63 69 65 6e 63 |nd for e|fficienc|
|00001920| 79 2e 20 2a 2f 0d 73 74 | 61 74 69 63 20 63 68 61 |y. */.st|atic cha|
|00001930| 72 20 2a 62 75 66 66 65 | 72 3b 09 09 2f 2a 20 54 |r *buffe|r;../* T|
|00001940| 68 65 20 62 75 66 66 65 | 72 20 69 74 73 65 6c 66 |he buffe|r itself|
|00001950| 2c 20 67 72 6f 77 6e 20 | 61 73 20 6e 65 65 64 65 |, grown |as neede|
|00001960| 64 2e 20 2a 2f 0d 73 74 | 61 74 69 63 20 62 75 66 |d. */.st|atic buf|
|00001970| 62 79 74 65 73 3b 09 09 | 2f 2a 20 4e 75 6d 62 65 |bytes;..|/* Numbe|
|00001980| 72 20 6f 66 20 62 79 74 | 65 73 20 69 6e 20 74 68 |r of byt|es in th|
|00001990| 65 20 62 75 66 66 65 72 | 2e 20 2a 2f 0d 73 74 61 |e buffer|. */.sta|
|000019a0| 74 69 63 20 73 69 7a 65 | 5f 74 20 62 75 66 61 6c |tic size|_t bufal|
|000019b0| 6c 6f 63 3b 09 09 2f 2a | 20 4e 75 6d 62 65 72 20 |loc;../*| Number |
|000019c0| 6f 66 20 62 79 74 65 73 | 20 61 6c 6c 6f 63 61 74 |of bytes| allocat|
|000019d0| 65 64 20 74 6f 20 74 68 | 65 20 62 75 66 66 65 72 |ed to th|e buffer|
|000019e0| 2e 20 2a 2f 0d 73 74 61 | 74 69 63 20 62 75 66 70 |. */.sta|tic bufp|
|000019f0| 72 65 76 3b 09 09 09 2f | 2a 20 4e 75 6d 62 65 72 |rev;.../|* Number|
|00001a00| 20 6f 66 20 62 79 74 65 | 73 20 74 68 61 74 20 68 | of byte|s that h|
|00001a10| 61 76 65 20 62 65 65 6e | 20 66 6f 72 67 6f 74 74 |ave been| forgott|
|00001a20| 65 6e 2e 0d 09 09 09 09 | 20 20 20 54 68 69 73 20 |en......| This |
|00001a30| 69 73 20 75 73 65 64 20 | 74 6f 20 67 65 74 20 62 |is used |to get b|
|00001a40| 79 74 65 20 6f 66 66 73 | 65 74 73 20 66 72 6f 6d |yte offs|ets from|
|00001a50| 20 74 68 65 0d 09 09 09 | 09 20 20 20 62 65 67 69 | the....|. begi|
|00001a60| 6e 6e 69 6e 67 20 6f 66 | 20 74 68 65 20 66 69 6c |nning of| the fil|
|00001a70| 65 2e 20 2a 2f 0d 73 74 | 61 74 69 63 20 62 75 66 |e. */.st|atic buf|
|00001a80| 72 65 61 64 3b 09 09 09 | 2f 2a 20 4e 75 6d 62 65 |read;...|/* Numbe|
|00001a90| 72 20 6f 66 20 62 79 74 | 65 73 20 74 6f 20 67 65 |r of byt|es to ge|
|00001aa0| 74 20 77 69 74 68 20 65 | 61 63 68 20 72 65 61 64 |t with e|ach read|
|00001ab0| 28 29 2e 20 2a 2f 0d 0d | 73 68 6f 72 74 20 57 65 |(). */..|short We|
|00001ac0| 41 72 65 53 74 6f 70 70 | 65 64 3b 0d 0d 73 74 61 |AreStopp|ed;..sta|
|00001ad0| 74 69 63 20 76 6f 69 64 | 0d 69 6e 69 74 69 61 6c |tic void|.initial|
|00001ae0| 69 7a 65 5f 62 75 66 66 | 65 72 28 29 0d 7b 0d 20 |ize_buff|er().{. |
|00001af0| 20 62 75 66 72 65 61 64 | 20 3d 20 38 31 39 32 3b | bufread| = 8192;|
|00001b00| 0d 20 20 62 75 66 61 6c | 6c 6f 63 20 3d 20 62 75 |. bufal|loc = bu|
|00001b10| 66 72 65 61 64 20 2b 20 | 62 75 66 72 65 61 64 20 |fread + |bufread |
|00001b20| 2f 20 32 3b 0d 20 20 62 | 75 66 66 65 72 20 3d 20 |/ 2;. b|uffer = |
|00001b30| 6d 61 6c 6c 6f 63 28 62 | 75 66 61 6c 6c 6f 63 29 |malloc(b|ufalloc)|
|00001b40| 3b 0d 20 20 69 66 20 28 | 21 20 62 75 66 66 65 72 |;. if (|! buffer|
|00001b50| 29 0d 20 20 20 20 7b 0d | 20 20 20 20 20 20 65 6d |). {.| em|
|00001b60| 69 74 64 61 74 61 28 20 | 22 25 73 3a 20 4d 65 6d |itdata( |"%s: Mem|
|00001b70| 6f 72 79 20 65 78 68 61 | 75 73 74 65 64 20 28 25 |ory exha|usted (%|
|00001b80| 73 29 5c 72 22 2c 20 70 | 72 6f 67 2c 0d 09 20 20 |s)\r", p|rog,.. |
|00001b90| 20 20 20 20 22 53 6f 6d | 65 20 65 72 72 6f 72 22 | "Som|e error"|
|00001ba0| 29 3b 0d 20 20 20 20 20 | 20 65 78 69 74 28 45 52 |);. | exit(ER|
|00001bb0| 52 4f 52 29 3b 0d 20 20 | 20 20 7d 0d 7d 0d 0d 2f |ROR);. | }.}../|
|00001bc0| 2a 20 54 68 65 20 63 75 | 72 72 65 6e 74 20 69 6e |* The cu|rrent in|
|00001bd0| 70 75 74 20 66 69 6c 65 | 2e 20 2a 2f 0d 73 74 61 |put file|. */.sta|
|00001be0| 74 69 63 20 66 64 3b 0d | 73 74 61 74 69 63 20 63 |tic fd;.|static c|
|00001bf0| 68 61 72 20 2a 66 69 6c | 65 6e 61 6d 65 3b 0d 73 |har *fil|ename;.s|
|00001c00| 74 61 74 69 63 20 65 6f | 66 3b 0d 0d 2f 2a 20 46 |tatic eo|f;../* F|
|00001c10| 69 6c 6c 20 74 68 65 20 | 62 75 66 66 65 72 20 72 |ill the |buffer r|
|00001c20| 65 74 61 69 6e 69 6e 67 | 20 74 68 65 20 6c 61 73 |etaining| the las|
|00001c30| 74 20 6e 20 62 79 74 65 | 73 20 61 74 20 74 68 65 |t n byte|s at the|
|00001c40| 20 62 65 67 69 6e 6e 69 | 6e 67 20 6f 66 20 74 68 | beginni|ng of th|
|00001c50| 65 0d 20 20 20 6e 65 77 | 6c 79 20 66 69 6c 6c 65 |e. new|ly fille|
|00001c60| 64 20 62 75 66 66 65 72 | 20 28 66 6f 72 20 62 61 |d buffer| (for ba|
|00001c70| 63 6b 77 61 72 64 20 63 | 6f 6e 74 65 78 74 29 2e |ckward c|ontext).|
|00001c80| 20 20 52 65 74 75 72 6e | 73 20 74 68 65 20 6e 75 | Return|s the nu|
|00001c90| 6d 62 65 72 20 6f 66 20 | 6e 65 77 0d 20 20 20 62 |mber of |new. b|
|00001ca0| 79 74 65 73 20 72 65 61 | 64 20 66 72 6f 6d 20 64 |ytes rea|d from d|
|00001cb0| 69 73 6b 2e 20 2a 2f 0d | 73 74 61 74 69 63 0d 66 |isk. */.|static.f|
|00001cc0| 69 6c 6c 5f 62 75 66 66 | 65 72 5f 72 65 74 61 69 |ill_buff|er_retai|
|00001cd0| 6e 69 6e 67 28 6e 29 0d | 20 20 20 20 20 69 6e 74 |ning(n).| int|
|00001ce0| 20 6e 3b 0d 7b 0d 20 20 | 63 68 61 72 20 2a 70 2c | n;.{. |char *p,|
|00001cf0| 20 2a 71 3b 0d 20 20 69 | 6e 74 20 69 3b 0d 0d 20 | *q;. i|nt i;.. |
|00001d00| 20 2f 2a 20 53 65 65 20 | 69 66 20 77 65 20 6e 65 | /* See |if we ne|
|00001d10| 65 64 20 74 6f 20 67 72 | 6f 77 20 74 68 65 20 62 |ed to gr|ow the b|
|00001d20| 75 66 66 65 72 2e 20 2a | 2f 0d 20 20 69 66 20 28 |uffer. *|/. if (|
|00001d30| 62 75 66 61 6c 6c 6f 63 | 20 2d 20 6e 20 3c 3d 20 |bufalloc| - n <= |
|00001d40| 62 75 66 72 65 61 64 29 | 0d 20 20 20 20 7b 0d 20 |bufread)|. {. |
|00001d50| 20 20 20 20 20 77 68 69 | 6c 65 20 28 62 75 66 61 | whi|le (bufa|
|00001d60| 6c 6c 6f 63 20 2d 20 6e | 20 3c 3d 20 62 75 66 72 |lloc - n| <= bufr|
|00001d70| 65 61 64 29 0d 09 7b 0d | 09 20 20 62 75 66 61 6c |ead)..{.|. bufal|
|00001d80| 6c 6f 63 20 2a 3d 20 32 | 3b 0d 09 20 20 62 75 66 |loc *= 2|;.. buf|
|00001d90| 72 65 61 64 20 2a 3d 20 | 32 3b 0d 09 7d 0d 20 20 |read *= |2;..}. |
|00001da0| 20 20 20 20 62 75 66 66 | 65 72 20 3d 20 72 65 61 | buff|er = rea|
|00001db0| 6c 6c 6f 63 28 62 75 66 | 66 65 72 2c 20 62 75 66 |lloc(buf|fer, buf|
|00001dc0| 61 6c 6c 6f 63 29 3b 0d | 20 20 20 20 20 20 69 66 |alloc);.| if|
|00001dd0| 20 28 21 20 62 75 66 66 | 65 72 29 0d 09 7b 0d 09 | (! buff|er)..{..|
|00001de0| 20 20 65 6d 69 74 64 61 | 74 61 28 20 22 25 73 3a | emitda|ta( "%s:|
|00001df0| 20 4d 65 6d 6f 72 79 20 | 65 78 68 61 75 73 74 65 | Memory |exhauste|
|00001e00| 64 20 28 25 73 29 5c 72 | 22 2c 20 70 72 6f 67 2c |d (%s)\r|", prog,|
|00001e10| 0d 09 09 20 20 22 53 6f | 6d 65 20 65 72 72 6f 72 |... "So|me error|
|00001e20| 22 29 3b 0d 09 20 20 65 | 78 69 74 28 45 52 52 4f |");.. e|xit(ERRO|
|00001e30| 52 29 3b 0d 09 7d 0d 20 | 20 20 20 7d 0d 0d 20 20 |R);..}. | }.. |
|00001e40| 62 75 66 70 72 65 76 20 | 2b 3d 20 62 75 66 62 79 |bufprev |+= bufby|
|00001e50| 74 65 73 20 2d 20 6e 3b | 0d 0d 20 20 2f 2a 20 53 |tes - n;|.. /* S|
|00001e60| 68 69 66 74 20 73 74 75 | 66 66 20 64 6f 77 6e 2e |hift stu|ff down.|
|00001e70| 20 2a 2f 0d 20 20 66 6f | 72 20 28 69 20 3d 20 6e | */. fo|r (i = n|
|00001e80| 2c 20 70 20 3d 20 62 75 | 66 66 65 72 2c 20 71 20 |, p = bu|ffer, q |
|00001e90| 3d 20 70 20 2b 20 62 75 | 66 62 79 74 65 73 20 2d |= p + bu|fbytes -|
|00001ea0| 20 6e 3b 20 69 2d 2d 3b | 20 29 0d 20 20 20 20 2a | n; i--;| ). *|
|00001eb0| 70 2b 2b 20 3d 20 2a 71 | 2b 2b 3b 0d 20 20 62 75 |p++ = *q|++;. bu|
|00001ec0| 66 62 79 74 65 73 20 3d | 20 6e 3b 0d 0d 20 20 69 |fbytes =| n;.. i|
|00001ed0| 66 20 28 65 6f 66 29 0d | 20 20 20 20 72 65 74 75 |f (eof).| retu|
|00001ee0| 72 6e 20 30 3b 0d 0d 20 | 20 2f 2a 20 52 65 61 64 |rn 0;.. | /* Read|
|00001ef0| 20 69 6e 20 6e 65 77 20 | 73 74 75 66 66 2e 20 2a | in new |stuff. *|
|00001f00| 2f 0d 20 20 69 20 3d 20 | 72 65 61 64 28 66 64 2c |/. i = |read(fd,|
|00001f10| 20 62 75 66 66 65 72 20 | 2b 20 62 75 66 62 79 74 | buffer |+ bufbyt|
|00001f20| 65 73 2c 20 62 75 66 72 | 65 61 64 29 3b 0d 20 20 |es, bufr|ead);. |
|00001f30| 43 68 65 63 6b 46 6f 72 | 42 72 65 61 6b 28 29 3b |CheckFor|Break();|
|00001f40| 0d 20 20 69 66 20 28 57 | 65 41 72 65 53 74 6f 70 |. if (W|eAreStop|
|00001f50| 70 65 64 29 20 69 20 3d | 20 30 3b 20 20 2f 2a 20 |ped) i =| 0; /* |
|00001f60| 65 78 69 74 20 74 68 69 | 73 20 74 68 69 6e 67 20 |exit thi|s thing |
|00001f70| 2a 2f 0d 20 20 69 66 20 | 28 69 20 3c 20 30 29 0d |*/. if |(i < 0).|
|00001f80| 20 20 20 20 7b 0d 20 20 | 20 20 20 20 65 6d 69 74 | {. | emit|
|00001f90| 64 61 74 61 28 20 22 25 | 73 3a 20 72 65 61 64 20 |data( "%|s: read |
|00001fa0| 6f 6e 20 25 73 20 66 61 | 69 6c 65 64 20 28 25 73 |on %s fa|iled (%s|
|00001fb0| 29 5c 72 22 2c 20 70 72 | 6f 67 2c 0d 09 20 20 20 |)\r", pr|og,.. |
|00001fc0| 20 20 20 66 69 6c 65 6e | 61 6d 65 20 3f 20 66 69 | filen|ame ? fi|
|00001fd0| 6c 65 6e 61 6d 65 20 3a | 20 22 3c 73 74 64 69 6e |lename :| "<stdin|
|00001fe0| 3e 22 2c 20 22 53 6f 6d | 65 20 65 72 72 6f 72 22 |>", "Som|e error"|
|00001ff0| 29 3b 0d 20 20 20 20 20 | 20 65 72 72 6f 72 20 3d |);. | error =|
|00002000| 20 31 3b 0d 20 20 20 20 | 7d 0d 0d 20 20 2f 2a 20 | 1;. |}.. /* |
|00002010| 4b 6c 75 64 67 65 20 74 | 6f 20 70 72 65 74 65 6e |Kludge t|o preten|
|00002020| 64 20 65 76 65 72 79 20 | 6e 6f 6e 65 6d 70 74 79 |d every |nonempty|
|00002030| 20 66 69 6c 65 20 65 6e | 64 73 20 77 69 74 68 20 | file en|ds with |
|00002040| 61 20 6e 65 77 6c 69 6e | 65 2e 20 2a 2f 0d 20 20 |a newlin|e. */. |
|00002050| 69 66 20 28 69 20 3d 3d | 20 30 20 26 26 20 62 75 |if (i ==| 0 && bu|
|00002060| 66 62 79 74 65 73 20 3e | 20 30 20 26 26 20 62 75 |fbytes >| 0 && bu|
|00002070| 66 66 65 72 5b 62 75 66 | 62 79 74 65 73 20 2d 20 |ffer[buf|bytes - |
|00002080| 31 5d 20 21 3d 20 27 5c | 72 27 29 20 20 2f 2a 20 |1] != '\|r') /* |
|00002090| 6e 65 77 6c 69 6e 65 20 | 63 68 61 6e 67 65 64 20 |newline |changed |
|000020a0| 2a 2f 0d 20 20 20 20 7b | 0d 20 20 20 20 20 20 65 |*/. {|. e|
|000020b0| 6f 66 20 3d 20 69 20 3d | 20 31 3b 0d 20 20 20 20 |of = i =| 1;. |
|000020c0| 20 20 62 75 66 66 65 72 | 5b 62 75 66 62 79 74 65 | buffer|[bufbyte|
|000020d0| 73 5d 20 3d 20 27 5c 72 | 27 3b 20 20 2f 2a 20 6e |s] = '\r|'; /* n|
|000020e0| 65 77 6c 69 6e 65 20 63 | 68 61 6e 67 65 64 20 2a |ewline c|hanged *|
|000020f0| 2f 0d 20 20 20 20 7d 0d | 0d 20 20 62 75 66 62 79 |/. }.|. bufby|
|00002100| 74 65 73 20 2b 3d 20 69 | 3b 0d 20 20 72 65 74 75 |tes += i|;. retu|
|00002110| 72 6e 20 69 3b 0d 7d 0d | 0c 0d 2f 2a 20 56 61 72 |rn i;.}.|../* Var|
|00002120| 69 6f 75 73 20 66 6c 61 | 67 73 20 73 65 74 20 61 |ious fla|gs set a|
|00002130| 63 63 6f 72 64 69 6e 67 | 20 74 6f 20 74 68 65 20 |ccording| to the |
|00002140| 61 72 67 75 6d 65 6e 74 | 20 73 77 69 74 63 68 65 |argument| switche|
|00002150| 73 2e 20 2a 2f 0d 73 74 | 61 74 69 63 20 74 72 61 |s. */.st|atic tra|
|00002160| 69 6c 69 6e 67 5f 63 6f | 6e 74 65 78 74 20 3d 20 |iling_co|ntext = |
|00002170| 30 3b 2f 2a 20 4c 69 6e | 65 73 20 6f 66 20 63 6f |0;/* Lin|es of co|
|00002180| 6e 74 65 78 74 20 74 6f | 20 73 68 6f 77 20 61 66 |ntext to| show af|
|00002190| 74 65 72 20 6d 61 74 63 | 68 65 73 2e 20 2a 2f 0d |ter matc|hes. */.|
|000021a0| 73 74 61 74 69 63 20 6c | 65 61 64 69 6e 67 5f 63 |static l|eading_c|
|000021b0| 6f 6e 74 65 78 74 20 3d | 20 30 3b 09 2f 2a 20 4c |ontext =| 0;./* L|
|000021c0| 69 6e 65 73 20 6f 66 20 | 63 6f 6e 74 65 78 74 20 |ines of |context |
|000021d0| 74 6f 20 73 68 6f 77 20 | 62 65 66 6f 72 65 20 6d |to show |before m|
|000021e0| 61 74 63 68 65 73 2e 20 | 2a 2f 0d 73 74 61 74 69 |atches. |*/.stati|
|000021f0| 63 20 62 79 74 65 5f 63 | 6f 75 6e 74 20 3d 20 30 |c byte_c|ount = 0|
|00002200| 3b 09 09 2f 2a 20 50 72 | 65 63 65 64 65 20 6f 75 |;../* Pr|ecede ou|
|00002210| 74 70 75 74 20 6c 69 6e | 65 73 20 74 68 65 20 62 |tput lin|es the b|
|00002220| 79 74 65 20 63 6f 75 6e | 74 20 6f 66 20 74 68 65 |yte coun|t of the|
|00002230| 0d 09 09 09 09 20 20 20 | 66 69 72 73 74 20 63 68 |..... |first ch|
|00002240| 61 72 61 63 74 65 72 20 | 6f 6e 20 74 68 65 20 6c |aracter |on the l|
|00002250| 69 6e 65 2e 20 2a 2f 0d | 73 74 61 74 69 63 20 6e |ine. */.|static n|
|00002260| 6f 5f 66 69 6c 65 6e 61 | 6d 65 73 20 3d 20 30 3b |o_filena|mes = 0;|
|00002270| 09 09 2f 2a 20 44 6f 20 | 6e 6f 74 20 64 69 73 70 |../* Do |not disp|
|00002280| 6c 61 79 20 66 69 6c 65 | 6e 61 6d 65 73 2e 20 2a |lay file|names. *|
|00002290| 2f 0d 73 74 61 74 69 63 | 20 6c 69 6e 65 5f 6e 75 |/.static| line_nu|
|000022a0| 6d 62 65 72 73 20 3d 20 | 30 3b 09 09 2f 2a 20 50 |mbers = |0;../* P|
|000022b0| 72 65 63 65 64 65 20 6f | 75 74 70 75 74 20 6c 69 |recede o|utput li|
|000022c0| 6e 65 73 20 77 69 74 68 | 20 6c 69 6e 65 20 6e 75 |nes with| line nu|
|000022d0| 6d 62 65 72 73 2e 20 2a | 2f 0d 73 74 61 74 69 63 |mbers. *|/.static|
|000022e0| 20 73 69 6c 65 6e 74 20 | 3d 20 30 3b 09 09 09 2f | silent |= 0;.../|
|000022f0| 2a 20 50 72 6f 64 75 63 | 65 20 6e 6f 20 6f 75 74 |* Produc|e no out|
|00002300| 70 75 74 20 61 74 20 61 | 6c 6c 2e 20 20 54 68 69 |put at a|ll. Thi|
|00002310| 73 20 73 77 69 74 63 68 | 0d 09 09 09 09 20 20 20 |s switch|..... |
|00002320| 69 73 20 62 6f 67 75 73 | 2c 20 65 76 65 72 20 68 |is bogus|, ever h|
|00002330| 65 61 72 20 6f 66 20 2f | 64 65 76 2f 6e 75 6c 6c |ear of /|dev/null|
|00002340| 3f 20 2a 2f 0d 73 74 61 | 74 69 63 20 6e 6f 6e 6d |? */.sta|tic nonm|
|00002350| 61 74 63 68 69 6e 67 5f | 6c 69 6e 65 73 20 3d 20 |atching_|lines = |
|00002360| 30 3b 09 2f 2a 20 50 72 | 69 6e 74 20 6c 69 6e 65 |0;./* Pr|int line|
|00002370| 73 20 74 68 61 74 20 64 | 6f 6e 27 74 20 6d 61 74 |s that d|on't mat|
|00002380| 63 68 20 74 68 65 20 72 | 65 67 65 78 70 2e 20 2a |ch the r|egexp. *|
|00002390| 2f 0d 0d 73 74 61 74 69 | 63 20 62 6d 67 65 78 65 |/..stati|c bmgexe|
|000023a0| 63 3b 09 09 09 2f 2a 20 | 49 6e 76 6f 6b 65 20 42 |c;.../* |Invoke B|
|000023b0| 6f 79 65 72 2d 4d 6f 6f | 72 65 2d 47 6f 73 70 65 |oyer-Moo|re-Gospe|
|000023c0| 72 20 72 6f 75 74 69 6e | 65 73 20 2a 2f 0d 0d 2f |r routin|es */../|
|000023d0| 2a 20 54 68 65 20 63 6f | 6d 70 69 6c 65 64 20 72 |* The co|mpiled r|
|000023e0| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|000023f0| 6e 20 6c 69 76 65 73 20 | 68 65 72 65 2e 20 2a 2f |n lives |here. */|
|00002400| 0d 73 74 61 74 69 63 20 | 73 74 72 75 63 74 20 72 |.static |struct r|
|00002410| 65 67 65 78 70 20 72 65 | 67 3b 0d 0d 2f 2a 20 54 |egexp re|g;../* T|
|00002420| 68 65 20 63 6f 6d 70 69 | 6c 65 64 20 72 65 67 75 |he compi|led regu|
|00002430| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 20 66 |lar expr|ession f|
|00002440| 6f 72 20 74 68 65 20 62 | 61 63 6b 74 72 61 63 6b |or the b|acktrack|
|00002450| 69 6e 67 20 6d 61 74 63 | 68 65 72 20 6c 69 76 65 |ing matc|her live|
|00002460| 73 20 68 65 72 65 2e 20 | 2a 2f 0d 73 74 61 74 69 |s here. |*/.stati|
|00002470| 63 20 73 74 72 75 63 74 | 20 72 65 5f 70 61 74 74 |c struct| re_patt|
|00002480| 65 72 6e 5f 62 75 66 66 | 65 72 20 72 65 67 65 78 |ern_buff|er regex|
|00002490| 3b 0d 0d 2f 2a 20 50 6f | 69 6e 74 65 72 20 69 6e |;../* Po|inter in|
|000024a0| 20 74 68 65 20 62 75 66 | 66 65 72 20 61 66 74 65 | the buf|fer afte|
|000024b0| 72 20 74 68 65 20 6c 61 | 73 74 20 63 68 61 72 61 |r the la|st chara|
|000024c0| 63 74 65 72 20 70 72 69 | 6e 74 65 64 2e 20 2a 2f |cter pri|nted. */|
|000024d0| 0d 73 74 61 74 69 63 20 | 63 68 61 72 20 2a 70 72 |.static |char *pr|
|000024e0| 69 6e 74 65 64 5f 6c 69 | 6d 69 74 3b 0d 0d 2f 2a |inted_li|mit;../*|
|000024f0| 20 54 72 75 65 20 77 68 | 65 6e 20 70 72 69 6e 74 | True wh|en print|
|00002500| 65 64 5f 6c 69 6d 69 74 | 20 68 61 73 20 62 65 65 |ed_limit| has bee|
|00002510| 6e 20 61 72 74 69 66 69 | 63 61 6c 6c 79 20 61 64 |n artifi|cally ad|
|00002520| 76 61 6e 63 65 64 20 77 | 69 74 68 6f 75 74 20 70 |vanced w|ithout p|
|00002530| 72 69 6e 74 69 6e 67 0d | 20 20 20 61 6e 79 74 68 |rinting.| anyth|
|00002540| 69 6e 67 2e 20 2a 2f 0d | 73 74 61 74 69 63 20 69 |ing. */.|static i|
|00002550| 6e 74 20 70 72 69 6e 74 | 65 64 5f 6c 69 6d 69 74 |nt print|ed_limit|
|00002560| 5f 66 61 6b 65 3b 0d 0d | 73 74 61 74 69 63 20 63 |_fake;..|static c|
|00002570| 68 61 72 20 70 72 62 75 | 66 5b 38 32 5d 3b 0d 73 |har prbu|f[82];.s|
|00002580| 74 61 74 69 63 20 70 72 | 62 75 66 69 6e 64 20 3d |tatic pr|bufind =|
|00002590| 20 30 3b 0d 0d 2f 2a 20 | 50 72 69 6e 74 20 61 20 | 0;../* |Print a |
|000025a0| 6c 69 6e 65 20 61 74 20 | 74 68 65 20 67 69 76 65 |line at |the give|
|000025b0| 6e 20 6c 69 6e 65 20 6e | 75 6d 62 65 72 2c 20 72 |n line n|umber, r|
|000025c0| 65 74 75 72 6e 69 6e 67 | 20 74 68 65 20 6e 75 6d |eturning| the num|
|000025d0| 62 65 72 20 6f 66 0d 20 | 20 20 63 68 61 72 61 63 |ber of. | charac|
|000025e0| 74 65 72 73 20 61 63 74 | 75 61 6c 6c 79 20 70 72 |ters act|ually pr|
|000025f0| 69 6e 74 65 64 2e 20 20 | 4d 61 74 63 68 69 6e 67 |inted. |Matching|
|00002600| 20 69 73 20 74 72 75 65 | 20 69 66 20 74 68 65 20 | is true| if the |
|00002610| 6c 69 6e 65 20 69 73 20 | 74 6f 0d 20 20 20 62 65 |line is |to. be|
|00002620| 20 63 6f 6e 73 69 64 65 | 72 65 64 20 61 20 22 6d | conside|red a "m|
|00002630| 61 74 63 68 69 6e 67 20 | 6c 69 6e 65 22 2e 20 20 |atching |line". |
|00002640| 54 68 69 73 20 69 73 20 | 6f 6e 6c 79 20 6d 65 61 |This is |only mea|
|00002650| 6e 69 6e 67 66 75 6c 20 | 69 66 0d 20 20 20 73 75 |ningful |if. su|
|00002660| 72 72 6f 75 6e 64 69 6e | 67 20 63 6f 6e 74 65 78 |rroundin|g contex|
|00002670| 74 20 69 73 20 74 75 72 | 6e 65 64 20 6f 6e 2e 20 |t is tur|ned on. |
|00002680| 2a 2f 0d 73 74 61 74 69 | 63 0d 70 72 69 6e 74 5f |*/.stati|c.print_|
|00002690| 6c 69 6e 65 28 70 2c 20 | 6e 75 6d 62 65 72 2c 20 |line(p, |number, |
|000026a0| 6d 61 74 63 68 69 6e 67 | 29 0d 20 20 20 20 20 63 |matching|). c|
|000026b0| 68 61 72 20 2a 70 3b 0d | 20 20 20 20 20 69 6e 74 |har *p;.| int|
|000026c0| 20 6e 75 6d 62 65 72 3b | 0d 20 20 20 20 20 69 6e | number;|. in|
|000026d0| 74 20 6d 61 74 63 68 69 | 6e 67 3b 0d 7b 0d 20 20 |t matchi|ng;.{. |
|000026e0| 69 6e 74 20 63 6f 75 6e | 74 20 3d 20 30 3b 0d 0d |int coun|t = 0;..|
|000026f0| 20 20 69 66 20 28 73 69 | 6c 65 6e 74 29 0d 20 20 | if (si|lent). |
|00002700| 20 20 7b 0d 20 20 20 20 | 20 20 64 6f 0d 09 2b 2b | {. | do..++|
|00002710| 63 6f 75 6e 74 3b 0d 20 | 20 20 20 20 20 77 68 69 |count;. | whi|
|00002720| 6c 65 20 28 2a 70 2b 2b | 20 21 3d 20 27 5c 72 27 |le (*p++| != '\r'|
|00002730| 29 3b 20 20 2f 2a 20 6e | 65 77 6c 69 6e 65 20 63 |); /* n|ewline c|
|00002740| 68 61 6e 67 65 64 20 2a | 2f 0d 20 20 20 20 20 20 |hanged *|/. |
|00002750| 70 72 69 6e 74 65 64 5f | 6c 69 6d 69 74 5f 66 61 |printed_|limit_fa|
|00002760| 6b 65 20 3d 20 30 3b 0d | 20 20 20 20 20 20 70 72 |ke = 0;.| pr|
|00002770| 69 6e 74 65 64 5f 6c 69 | 6d 69 74 20 3d 20 70 3b |inted_li|mit = p;|
|00002780| 0d 20 20 20 20 20 20 72 | 65 74 75 72 6e 20 63 6f |. r|eturn co|
|00002790| 75 6e 74 3b 0d 20 20 20 | 20 7d 0d 0d 20 20 69 66 |unt;. | }.. if|
|000027a0| 20 28 66 69 6c 65 6e 61 | 6d 65 20 26 26 20 21 6e | (filena|me && !n|
|000027b0| 6f 5f 66 69 6c 65 6e 61 | 6d 65 73 29 0d 20 20 20 |o_filena|mes). |
|000027c0| 20 65 6d 69 74 64 61 74 | 61 28 22 25 73 25 63 22 | emitdat|a("%s%c"|
|000027d0| 2c 20 66 69 6c 65 6e 61 | 6d 65 2c 20 6d 61 74 63 |, filena|me, matc|
|000027e0| 68 69 6e 67 20 3f 20 27 | 3a 27 20 3a 20 27 2d 27 |hing ? '|:' : '-'|
|000027f0| 29 3b 0d 20 20 69 66 20 | 28 62 79 74 65 5f 63 6f |);. if |(byte_co|
|00002800| 75 6e 74 29 0d 20 20 20 | 20 65 6d 69 74 64 61 74 |unt). | emitdat|
|00002810| 61 28 22 25 64 25 63 22 | 2c 20 70 20 2d 20 62 75 |a("%d%c"|, p - bu|
|00002820| 66 66 65 72 20 2b 20 62 | 75 66 70 72 65 76 2c 20 |ffer + b|ufprev, |
|00002830| 6d 61 74 63 68 69 6e 67 | 20 3f 20 27 3a 27 20 3a |matching| ? ':' :|
|00002840| 20 27 2d 27 29 3b 0d 20 | 20 69 66 20 28 6c 69 6e | '-');. | if (lin|
|00002850| 65 5f 6e 75 6d 62 65 72 | 73 29 0d 20 20 20 20 65 |e_number|s). e|
|00002860| 6d 69 74 64 61 74 61 28 | 22 25 64 25 63 22 2c 20 |mitdata(|"%d%c", |
|00002870| 6e 75 6d 62 65 72 2c 20 | 6d 61 74 63 68 69 6e 67 |number, |matching|
|00002880| 20 3f 20 27 3a 27 20 3a | 20 27 2d 27 29 3b 0d 20 | ? ':' :| '-');. |
|00002890| 20 64 6f 0d 20 20 20 20 | 7b 0d 20 20 20 20 20 20 | do. |{. |
|000028a0| 2b 2b 63 6f 75 6e 74 3b | 0d 20 20 20 20 20 20 69 |++count;|. i|
|000028b0| 66 20 28 2a 70 20 3d 3d | 20 27 5c 72 27 29 20 7b |f (*p ==| '\r') {|
|000028c0| 0d 20 20 20 20 20 20 20 | 20 20 70 72 62 75 66 5b |. | prbuf[|
|000028d0| 70 72 62 75 66 69 6e 64 | 5d 20 3d 20 27 5c 72 27 |prbufind|] = '\r'|
|000028e0| 3b 0d 20 20 20 20 20 20 | 20 20 20 70 72 62 75 66 |;. | prbuf|
|000028f0| 69 6e 64 2b 2b 3b 0d 20 | 20 20 20 20 20 20 20 20 |ind++;. | |
|00002900| 70 72 62 75 66 5b 70 72 | 62 75 66 69 6e 64 5d 20 |prbuf[pr|bufind] |
|00002910| 3d 20 27 5c 30 27 3b 0d | 20 20 20 20 20 20 20 20 |= '\0';.| |
|00002920| 20 65 6d 69 74 64 61 74 | 61 28 22 25 73 22 2c 20 | emitdat|a("%s", |
|00002930| 70 72 62 75 66 29 3b 0d | 20 20 20 20 20 20 20 20 |prbuf);.| |
|00002940| 20 70 72 62 75 66 69 6e | 64 20 3d 20 30 3b 0d 20 | prbufin|d = 0;. |
|00002950| 20 20 20 20 20 7d 20 65 | 6c 73 65 20 7b 0d 20 20 | } e|lse {. |
|00002960| 20 20 20 20 20 20 20 70 | 72 62 75 66 5b 70 72 62 | p|rbuf[prb|
|00002970| 75 66 69 6e 64 5d 20 3d | 20 2a 70 3b 0d 20 20 20 |ufind] =| *p;. |
|00002980| 20 20 20 20 20 20 70 72 | 62 75 66 69 6e 64 2b 2b | pr|bufind++|
|00002990| 3b 0d 20 20 20 20 20 20 | 20 20 20 69 66 20 28 70 |;. | if (p|
|000029a0| 72 62 75 66 69 6e 64 20 | 3d 3d 20 38 30 29 20 7b |rbufind |== 80) {|
|000029b0| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 70 72 62 |. | prb|
|000029c0| 75 66 5b 70 72 62 75 66 | 69 6e 64 5d 20 3d 20 27 |uf[prbuf|ind] = '|
|000029d0| 5c 30 27 3b 0d 20 20 20 | 20 20 20 20 20 20 20 20 |\0';. | |
|000029e0| 20 65 6d 69 74 64 61 74 | 61 28 22 25 73 22 2c 20 | emitdat|a("%s", |
|000029f0| 70 72 62 75 66 29 3b 0d | 20 20 20 20 20 20 20 20 |prbuf);.| |
|00002a00| 20 20 20 20 70 72 62 75 | 66 69 6e 64 20 3d 20 30 | prbu|find = 0|
|00002a10| 3b 0d 20 20 20 20 20 20 | 20 20 20 7d 0d 20 20 20 |;. | }. |
|00002a20| 20 20 20 7d 0d 20 20 20 | 20 7d 0d 20 20 77 68 69 | }. | }. whi|
|00002a30| 6c 65 20 28 2a 70 2b 2b | 20 21 3d 20 27 5c 72 27 |le (*p++| != '\r'|
|00002a40| 29 3b 20 20 2f 2a 20 6e | 65 77 6c 69 6e 65 20 63 |); /* n|ewline c|
|00002a50| 68 61 6e 67 65 64 20 2a | 2f 0d 20 20 70 72 69 6e |hanged *|/. prin|
|00002a60| 74 65 64 5f 6c 69 6d 69 | 74 5f 66 61 6b 65 20 3d |ted_limi|t_fake =|
|00002a70| 20 30 3b 0d 20 20 70 72 | 69 6e 74 65 64 5f 6c 69 | 0;. pr|inted_li|
|00002a80| 6d 69 74 20 3d 20 70 3b | 0d 20 20 72 65 74 75 72 |mit = p;|. retur|
|00002a90| 6e 20 63 6f 75 6e 74 3b | 0d 7d 0d 0d 2f 2a 20 50 |n count;|.}../* P|
|00002aa0| 72 69 6e 74 20 6d 61 74 | 63 68 69 6e 67 20 6f 72 |rint mat|ching or|
|00002ab0| 20 6e 6f 6e 6d 61 74 63 | 68 69 6e 67 20 6c 69 6e | nonmatc|hing lin|
|00002ac0| 65 73 20 66 72 6f 6d 20 | 74 68 65 20 63 75 72 72 |es from |the curr|
|00002ad0| 65 6e 74 20 66 69 6c 65 | 2e 20 20 52 65 74 75 72 |ent file|. Retur|
|00002ae0| 6e 73 20 61 0d 20 20 20 | 63 6f 75 6e 74 20 6f 66 |ns a. |count of|
|00002af0| 20 6d 61 74 63 68 69 6e | 67 20 6f 72 20 6e 6f 6e | matchin|g or non|
|00002b00| 6d 61 74 63 68 69 6e 67 | 20 6c 69 6e 65 73 2e 20 |matching| lines. |
|00002b10| 2a 2f 0d 73 74 61 74 69 | 63 0d 67 72 65 70 28 29 |*/.stati|c.grep()|
|00002b20| 0d 7b 0d 20 20 69 6e 74 | 20 72 65 74 61 69 6e 20 |.{. int| retain |
|00002b30| 3d 20 30 3b 09 09 2f 2a | 20 4e 75 6d 62 65 72 20 |= 0;../*| Number |
|00002b40| 6f 66 20 62 79 74 65 73 | 20 74 6f 20 72 65 74 61 |of bytes| to reta|
|00002b50| 69 6e 20 6f 6e 20 6e 65 | 78 74 20 63 61 6c 6c 0d |in on ne|xt call.|
|00002b60| 09 09 09 09 20 20 20 74 | 6f 20 66 69 6c 6c 5f 62 |.... t|o fill_b|
|00002b70| 75 66 66 65 72 5f 72 65 | 74 61 69 6e 69 6e 67 28 |uffer_re|taining(|
|00002b80| 29 2e 20 2a 2f 0d 20 20 | 63 68 61 72 20 2a 73 65 |). */. |char *se|
|00002b90| 61 72 63 68 5f 6c 69 6d | 69 74 3b 09 09 2f 2a 20 |arch_lim|it;../* |
|00002ba0| 50 6f 69 6e 74 65 72 20 | 74 6f 20 74 68 65 20 63 |Pointer |to the c|
|00002bb0| 68 61 72 61 63 74 65 72 | 20 61 66 74 65 72 20 74 |haracter| after t|
|00002bc0| 68 65 20 6c 61 73 74 0d | 09 09 09 09 20 20 20 6e |he last.|.... n|
|00002bd0| 65 77 6c 69 6e 65 20 69 | 6e 20 74 68 65 20 62 75 |ewline i|n the bu|
|00002be0| 66 66 65 72 2e 20 2a 2f | 0d 20 20 63 68 61 72 20 |ffer. */|. char |
|00002bf0| 73 61 76 65 64 5f 63 68 | 61 72 3b 09 09 2f 2a 20 |saved_ch|ar;../* |
|00002c00| 43 68 61 72 61 63 74 65 | 72 20 61 66 74 65 72 20 |Characte|r after |
|00002c10| 74 68 65 20 6c 61 73 74 | 20 6e 65 77 6c 69 6e 65 |the last| newline|
|00002c20| 2e 20 2a 2f 0d 20 20 63 | 68 61 72 20 2a 72 65 73 |. */. c|har *res|
|00002c30| 75 6d 65 3b 09 09 09 2f | 2a 20 50 6f 69 6e 74 65 |ume;.../|* Pointe|
|00002c40| 72 20 74 6f 20 77 68 65 | 72 65 20 74 6f 20 72 65 |r to whe|re to re|
|00002c50| 73 75 6d 65 20 73 65 61 | 72 63 68 2e 20 2a 2f 0d |sume sea|rch. */.|
|00002c60| 20 20 69 6e 74 20 72 65 | 73 75 6d 65 5f 69 6e 64 | int re|sume_ind|
|00002c70| 65 78 20 3d 20 30 3b 09 | 09 2f 2a 20 43 6f 75 6e |ex = 0;.|./* Coun|
|00002c80| 74 20 6f 66 20 63 68 61 | 72 61 63 74 65 72 73 20 |t of cha|racters |
|00002c90| 74 6f 20 69 67 6e 6f 72 | 65 20 61 66 74 65 72 0d |to ignor|e after.|
|00002ca0| 09 09 09 09 20 20 20 72 | 65 66 69 6c 6c 69 6e 67 |.... r|efilling|
|00002cb0| 20 74 68 65 20 62 75 66 | 66 65 72 2e 20 2a 2f 0d | the buf|fer. */.|
|00002cc0| 20 20 69 6e 74 20 6c 69 | 6e 65 5f 63 6f 75 6e 74 | int li|ne_count|
|00002cd0| 20 3d 20 31 3b 09 09 2f | 2a 20 4c 69 6e 65 20 6e | = 1;../|* Line n|
|00002ce0| 75 6d 62 65 72 2e 20 2a | 2f 0d 20 20 69 6e 74 20 |umber. *|/. int |
|00002cf0| 74 72 79 5f 62 61 63 6b | 72 65 66 3b 09 09 2f 2a |try_back|ref;../*|
|00002d00| 20 53 65 74 20 74 6f 20 | 74 72 75 65 20 69 66 20 | Set to |true if |
|00002d10| 77 65 20 6e 65 65 64 20 | 74 6f 20 76 65 72 69 66 |we need |to verif|
|00002d20| 79 20 74 68 65 0d 09 09 | 09 09 20 20 20 6d 61 74 |y the...|.. mat|
|00002d30| 63 68 20 77 69 74 68 20 | 61 20 62 61 63 6b 74 72 |ch with |a backtr|
|00002d40| 61 63 6b 69 6e 67 20 6d | 61 74 63 68 65 72 2e 20 |acking m|atcher. |
|00002d50| 2a 2f 0d 20 20 69 6e 74 | 20 69 6e 69 74 69 61 6c |*/. int| initial|
|00002d60| 5f 6c 69 6e 65 5f 63 6f | 75 6e 74 3b 09 2f 2a 20 |_line_co|unt;./* |
|00002d70| 4c 69 6e 65 20 63 6f 75 | 6e 74 20 61 74 20 62 65 |Line cou|nt at be|
|00002d80| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 6c 61 73 74 20 |ginning |of last |
|00002d90| 73 65 61 72 63 68 2e 20 | 2a 2f 0d 20 20 63 68 61 |search. |*/. cha|
|00002da0| 72 20 2a 6d 61 74 63 68 | 3b 09 09 09 2f 2a 20 50 |r *match|;.../* P|
|00002db0| 6f 69 6e 74 65 72 20 74 | 6f 20 74 68 65 20 66 69 |ointer t|o the fi|
|00002dc0| 72 73 74 20 63 68 61 72 | 61 63 74 65 72 20 61 66 |rst char|acter af|
|00002dd0| 74 65 72 20 74 68 65 0d | 09 09 09 09 20 20 20 73 |ter the.|.... s|
|00002de0| 74 72 69 6e 67 20 6d 61 | 74 63 68 69 6e 67 20 74 |tring ma|tching t|
|00002df0| 68 65 20 72 65 67 65 78 | 70 2e 20 2a 2f 0d 20 20 |he regex|p. */. |
|00002e00| 69 6e 74 20 6d 61 74 63 | 68 5f 63 6f 75 6e 74 20 |int matc|h_count |
|00002e10| 3d 20 30 3b 09 09 2f 2a | 20 43 6f 75 6e 74 20 6f |= 0;../*| Count o|
|00002e20| 66 20 6d 61 74 63 68 69 | 6e 67 20 6c 69 6e 65 73 |f matchi|ng lines|
|00002e30| 2e 20 2a 2f 0d 20 20 63 | 68 61 72 20 2a 6d 61 74 |. */. c|har *mat|
|00002e40| 63 68 69 6e 67 5f 6c 69 | 6e 65 3b 09 09 2f 2a 20 |ching_li|ne;../* |
|00002e50| 50 6f 69 6e 74 65 72 20 | 74 6f 20 66 69 72 73 74 |Pointer |to first|
|00002e60| 20 63 68 61 72 61 63 74 | 65 72 20 6f 66 20 74 68 | charact|er of th|
|00002e70| 65 20 6d 61 74 63 68 69 | 6e 67 0d 09 09 09 09 20 |e matchi|ng..... |
|00002e80| 20 20 6c 69 6e 65 2c 20 | 6f 72 20 6f 66 20 74 68 | line, |or of th|
|00002e90| 65 20 66 69 72 73 74 20 | 6c 69 6e 65 20 6f 66 20 |e first |line of |
|00002ea0| 63 6f 6e 74 65 78 74 20 | 74 6f 0d 09 09 09 09 20 |context |to..... |
|00002eb0| 20 20 70 72 69 6e 74 20 | 69 66 20 63 6f 6e 74 65 | print |if conte|
|00002ec0| 78 74 20 69 73 20 74 75 | 72 6e 65 64 20 6f 6e 2e |xt is tu|rned on.|
|00002ed0| 20 2a 2f 0d 20 20 63 68 | 61 72 20 2a 72 65 61 6c | */. ch|ar *real|
|00002ee0| 5f 6d 61 74 63 68 69 6e | 67 5f 6c 69 6e 65 3b 09 |_matchin|g_line;.|
|00002ef0| 2f 2a 20 50 6f 69 6e 74 | 65 72 20 74 6f 20 74 68 |/* Point|er to th|
|00002f00| 65 20 66 69 72 73 74 20 | 63 68 61 72 61 63 74 65 |e first |characte|
|00002f10| 72 20 6f 66 20 74 68 65 | 0d 09 09 09 09 20 20 20 |r of the|..... |
|00002f20| 72 65 61 6c 20 6d 61 74 | 63 68 69 6e 67 20 6c 69 |real mat|ching li|
|00002f30| 6e 65 2e 20 2a 2f 0d 20 | 20 63 68 61 72 20 2a 6e |ne. */. | char *n|
|00002f40| 65 78 74 5f 6c 69 6e 65 | 3b 09 09 2f 2a 20 50 6f |ext_line|;../* Po|
|00002f50| 69 6e 74 65 72 20 74 6f | 20 66 69 72 73 74 20 63 |inter to| first c|
|00002f60| 68 61 72 61 63 74 65 72 | 20 6f 66 20 74 68 65 20 |haracter| of the |
|00002f70| 6c 69 6e 65 0d 09 09 09 | 09 20 20 20 66 6f 6c 6c |line....|. foll|
|00002f80| 6f 77 69 6e 67 20 74 68 | 65 20 6d 61 74 63 68 69 |owing th|e matchi|
|00002f90| 6e 67 20 6c 69 6e 65 2e | 20 2a 2f 0d 20 20 69 6e |ng line.| */. in|
|00002fa0| 74 20 70 65 6e 64 69 6e | 67 5f 6c 69 6e 65 73 20 |t pendin|g_lines |
|00002fb0| 3d 20 30 3b 09 2f 2a 20 | 4c 69 6e 65 73 20 6f 66 |= 0;./* |Lines of|
|00002fc0| 20 63 6f 6e 74 65 78 74 | 20 6c 65 66 74 20 6f 76 | context| left ov|
|00002fd0| 65 72 20 66 72 6f 6d 20 | 6c 61 73 74 20 6d 61 74 |er from |last mat|
|00002fe0| 63 68 0d 09 09 09 09 20 | 20 20 74 68 61 74 20 77 |ch..... | that w|
|00002ff0| 65 20 68 61 76 65 20 74 | 6f 20 70 72 69 6e 74 2e |e have t|o print.|
|00003000| 20 2a 2f 0d 20 20 73 74 | 61 74 69 63 20 66 69 72 | */. st|atic fir|
|00003010| 73 74 5f 6d 61 74 63 68 | 20 3d 20 31 3b 09 2f 2a |st_match| = 1;./*|
|00003020| 20 54 72 75 65 20 77 68 | 65 6e 20 6e 6f 74 68 69 | True wh|en nothi|
|00003030| 6e 67 20 68 61 73 20 62 | 65 65 6e 20 70 72 69 6e |ng has b|een prin|
|00003040| 74 65 64 2e 20 2a 2f 0d | 20 20 69 6e 74 20 69 3b |ted. */.| int i;|
|00003050| 0d 20 20 63 68 61 72 20 | 2a 74 6d 70 3b 0d 20 20 |. char |*tmp;. |
|00003060| 63 68 61 72 20 2a 65 78 | 65 63 75 74 65 28 29 3b |char *ex|ecute();|
|00003070| 0d 0d 20 20 70 72 69 6e | 74 65 64 5f 6c 69 6d 69 |.. prin|ted_limi|
|00003080| 74 5f 66 61 6b 65 20 3d | 20 30 3b 0d 20 20 0d 20 |t_fake =| 0;. . |
|00003090| 20 77 68 69 6c 65 20 28 | 66 69 6c 6c 5f 62 75 66 | while (|fill_buf|
|000030a0| 66 65 72 5f 72 65 74 61 | 69 6e 69 6e 67 28 72 65 |fer_reta|ining(re|
|000030b0| 74 61 69 6e 29 20 3e 20 | 30 29 0d 20 20 20 20 7b |tain) > |0). {|
|000030c0| 0d 20 20 20 20 20 20 2f | 2a 20 46 69 6e 64 20 74 |. /|* Find t|
|000030d0| 68 65 20 6c 61 73 74 20 | 6e 65 77 6c 69 6e 65 20 |he last |newline |
|000030e0| 69 6e 20 74 68 65 20 62 | 75 66 66 65 72 2e 20 2a |in the b|uffer. *|
|000030f0| 2f 0d 20 20 20 20 20 20 | 73 65 61 72 63 68 5f 6c |/. |search_l|
|00003100| 69 6d 69 74 20 3d 20 62 | 75 66 66 65 72 20 2b 20 |imit = b|uffer + |
|00003110| 62 75 66 62 79 74 65 73 | 3b 0d 20 20 20 20 20 20 |bufbytes|;. |
|00003120| 77 68 69 6c 65 20 28 73 | 65 61 72 63 68 5f 6c 69 |while (s|earch_li|
|00003130| 6d 69 74 20 3e 20 62 75 | 66 66 65 72 20 26 26 20 |mit > bu|ffer && |
|00003140| 73 65 61 72 63 68 5f 6c | 69 6d 69 74 5b 2d 31 5d |search_l|imit[-1]|
|00003150| 20 21 3d 20 27 5c 72 27 | 29 20 20 2f 2a 20 6e 65 | != '\r'|) /* ne|
|00003160| 77 6c 69 6e 65 20 63 68 | 61 6e 67 65 64 20 2a 2f |wline ch|anged */|
|00003170| 0d 09 2d 2d 73 65 61 72 | 63 68 5f 6c 69 6d 69 74 |..--sear|ch_limit|
|00003180| 3b 0d 20 20 20 20 20 20 | 69 66 20 28 73 65 61 72 |;. |if (sear|
|00003190| 63 68 5f 6c 69 6d 69 74 | 20 3d 3d 20 62 75 66 66 |ch_limit| == buff|
|000031a0| 65 72 29 0d 09 7b 0d 09 | 20 20 72 65 74 61 69 6e |er)..{..| retain|
|000031b0| 20 3d 20 62 75 66 62 79 | 74 65 73 3b 0d 09 20 20 | = bufby|tes;.. |
|000031c0| 63 6f 6e 74 69 6e 75 65 | 3b 0d 09 7d 0d 0d 20 20 |continue|;..}.. |
|000031d0| 20 20 20 20 2f 2a 20 53 | 61 76 65 20 74 68 65 20 | /* S|ave the |
|000031e0| 63 68 61 72 61 63 74 65 | 72 20 61 66 74 65 72 20 |characte|r after |
|000031f0| 74 68 65 20 6c 61 73 74 | 20 6e 65 77 6c 69 6e 65 |the last| newline|
|00003200| 20 73 6f 20 72 65 67 65 | 78 65 63 75 74 65 20 63 | so rege|xecute c|
|00003210| 61 6e 20 77 72 69 74 65 | 0d 09 20 69 74 73 20 6f |an write|.. its o|
|00003220| 77 6e 20 73 65 6e 74 69 | 6e 65 6c 20 6e 65 77 6c |wn senti|nel newl|
|00003230| 69 6e 65 2e 20 2a 2f 0d | 20 20 20 20 20 20 73 61 |ine. */.| sa|
|00003240| 76 65 64 5f 63 68 61 72 | 20 3d 20 2a 73 65 61 72 |ved_char| = *sear|
|00003250| 63 68 5f 6c 69 6d 69 74 | 3b 0d 0d 20 20 20 20 20 |ch_limit|;.. |
|00003260| 20 2f 2a 20 53 65 61 72 | 63 68 20 74 68 65 20 62 | /* Sear|ch the b|
|00003270| 75 66 66 65 72 20 66 6f | 72 20 61 20 6d 61 74 63 |uffer fo|r a matc|
|00003280| 68 2e 20 2a 2f 0d 20 20 | 20 20 20 20 70 72 69 6e |h. */. | prin|
|00003290| 74 65 64 5f 6c 69 6d 69 | 74 20 3d 20 62 75 66 66 |ted_limi|t = buff|
|000032a0| 65 72 3b 0d 20 20 20 20 | 20 20 72 65 73 75 6d 65 |er;. | resume|
|000032b0| 20 3d 20 62 75 66 66 65 | 72 20 2b 20 72 65 73 75 | = buffe|r + resu|
|000032c0| 6d 65 5f 69 6e 64 65 78 | 3b 0d 20 20 20 20 20 20 |me_index|;. |
|000032d0| 69 6e 69 74 69 61 6c 5f | 6c 69 6e 65 5f 63 6f 75 |initial_|line_cou|
|000032e0| 6e 74 20 3d 20 6c 69 6e | 65 5f 63 6f 75 6e 74 3b |nt = lin|e_count;|
|000032f0| 0d 0d 20 20 20 20 20 20 | 77 68 69 6c 65 20 28 6d |.. |while (m|
|00003300| 61 74 63 68 20 3d 20 65 | 78 65 63 75 74 65 28 26 |atch = e|xecute(&|
|00003310| 72 65 67 2c 20 72 65 73 | 75 6d 65 2c 20 73 65 61 |reg, res|ume, sea|
|00003320| 72 63 68 5f 6c 69 6d 69 | 74 2c 20 30 2c 20 26 6c |rch_limi|t, 0, &l|
|00003330| 69 6e 65 5f 63 6f 75 6e | 74 2c 20 26 74 72 79 5f |ine_coun|t, &try_|
|00003340| 62 61 63 6b 72 65 66 29 | 29 0d 09 7b 0d 09 20 20 |backref)|)..{.. |
|00003350| 2b 2b 6d 61 74 63 68 5f | 63 6f 75 6e 74 3b 0d 0d |++match_|count;..|
|00003360| 09 20 20 2f 2a 20 46 69 | 6e 64 20 74 68 65 20 62 |. /* Fi|nd the b|
|00003370| 65 67 69 6e 6e 69 6e 67 | 20 6f 66 20 74 68 65 20 |eginning| of the |
|00003380| 6d 61 74 63 68 69 6e 67 | 20 6c 69 6e 65 2e 20 2a |matching| line. *|
|00003390| 2f 0d 09 20 20 6d 61 74 | 63 68 69 6e 67 5f 6c 69 |/.. mat|ching_li|
|000033a0| 6e 65 20 3d 20 6d 61 74 | 63 68 3b 0d 09 20 20 77 |ne = mat|ch;.. w|
|000033b0| 68 69 6c 65 20 28 6d 61 | 74 63 68 69 6e 67 5f 6c |hile (ma|tching_l|
|000033c0| 69 6e 65 20 3e 20 72 65 | 73 75 6d 65 20 26 26 20 |ine > re|sume && |
|000033d0| 6d 61 74 63 68 69 6e 67 | 5f 6c 69 6e 65 5b 2d 31 |matching|_line[-1|
|000033e0| 5d 20 21 3d 20 27 5c 72 | 27 29 20 20 2f 2a 20 6e |] != '\r|') /* n|
|000033f0| 65 77 6c 69 6e 65 20 63 | 68 61 6e 67 65 64 20 2a |ewline c|hanged *|
|00003400| 2f 0d 09 20 20 20 20 2d | 2d 6d 61 74 63 68 69 6e |/.. -|-matchin|
|00003410| 67 5f 6c 69 6e 65 3b 0d | 09 20 20 72 65 61 6c 5f |g_line;.|. real_|
|00003420| 6d 61 74 63 68 69 6e 67 | 5f 6c 69 6e 65 20 3d 20 |matching|_line = |
|00003430| 6d 61 74 63 68 69 6e 67 | 5f 6c 69 6e 65 3b 0d 0d |matching|_line;..|
|00003440| 09 20 20 2f 2a 20 46 69 | 6e 64 20 74 68 65 20 62 |. /* Fi|nd the b|
|00003450| 65 67 69 6e 6e 69 6e 67 | 20 6f 66 20 74 68 65 20 |eginning| of the |
|00003460| 6e 65 78 74 20 6c 69 6e | 65 2e 20 2a 2f 0d 09 20 |next lin|e. */.. |
|00003470| 20 6e 65 78 74 5f 6c 69 | 6e 65 20 3d 20 6d 61 74 | next_li|ne = mat|
|00003480| 63 68 3b 0d 09 20 20 77 | 68 69 6c 65 20 28 6e 65 |ch;.. w|hile (ne|
|00003490| 78 74 5f 6c 69 6e 65 20 | 3c 20 73 65 61 72 63 68 |xt_line |< search|
|000034a0| 5f 6c 69 6d 69 74 20 26 | 26 20 2a 6e 65 78 74 5f |_limit &|& *next_|
|000034b0| 6c 69 6e 65 2b 2b 20 21 | 3d 20 27 5c 72 27 29 20 |line++ !|= '\r') |
|000034c0| 20 2f 2a 20 6e 65 77 6c | 69 6e 65 20 63 68 61 6e | /* newl|ine chan|
|000034d0| 67 65 64 20 2a 2f 0d 09 | 20 20 20 20 3b 0d 0d 09 |ged */..| ;...|
|000034e0| 20 20 2f 2a 20 49 66 20 | 61 20 70 6f 74 65 6e 74 | /* If |a potent|
|000034f0| 69 61 6c 20 62 61 63 6b | 72 65 66 65 72 65 6e 63 |ial back|referenc|
|00003500| 65 20 69 73 20 69 6e 64 | 69 63 61 74 65 64 2c 20 |e is ind|icated, |
|00003510| 74 72 79 20 69 74 20 6f | 75 74 20 77 69 74 68 0d |try it o|ut with.|
|00003520| 09 20 20 20 20 20 61 20 | 62 61 63 6b 74 72 61 63 |. a |backtrac|
|00003530| 6b 69 6e 67 20 6d 61 74 | 63 68 65 72 20 74 6f 20 |king mat|cher to |
|00003540| 6d 61 6b 65 20 73 75 72 | 65 20 74 68 65 20 6c 69 |make sur|e the li|
|00003550| 6e 65 20 69 73 20 61 20 | 6d 61 74 63 68 2e 20 2a |ne is a |match. *|
|00003560| 2f 0d 09 20 20 69 66 20 | 28 74 72 79 5f 62 61 63 |/.. if |(try_bac|
|00003570| 6b 72 65 66 20 26 26 20 | 72 65 5f 73 65 61 72 63 |kref && |re_searc|
|00003580| 68 28 26 72 65 67 65 78 | 2c 20 6d 61 74 63 68 69 |h(&regex|, matchi|
|00003590| 6e 67 5f 6c 69 6e 65 2c | 0d 09 09 09 09 20 20 20 |ng_line,|..... |
|000035a0| 20 20 20 20 6e 65 78 74 | 5f 6c 69 6e 65 20 2d 20 | next|_line - |
|000035b0| 6d 61 74 63 68 69 6e 67 | 5f 6c 69 6e 65 20 2d 20 |matching|_line - |
|000035c0| 31 2c 0d 09 09 09 09 20 | 20 20 20 20 20 20 30 2c |1,..... | 0,|
|000035d0| 0d 09 09 09 09 20 20 20 | 20 20 20 20 6e 65 78 74 |..... | next|
|000035e0| 5f 6c 69 6e 65 20 2d 20 | 6d 61 74 63 68 69 6e 67 |_line - |matching|
|000035f0| 5f 6c 69 6e 65 20 2d 20 | 31 2c 0d 09 09 09 09 20 |_line - |1,..... |
|00003600| 20 20 20 20 20 20 4e 55 | 4c 4c 29 20 3c 20 30 29 | NU|LL) < 0)|
|00003610| 0d 09 20 20 20 20 7b 0d | 09 20 20 20 20 20 20 72 |.. {.|. r|
|00003620| 65 73 75 6d 65 20 3d 20 | 6e 65 78 74 5f 6c 69 6e |esume = |next_lin|
|00003630| 65 3b 0d 09 20 20 20 20 | 20 20 69 66 20 28 72 65 |e;.. | if (re|
|00003640| 73 75 6d 65 20 3d 3d 20 | 73 65 61 72 63 68 5f 6c |sume == |search_l|
|00003650| 69 6d 69 74 29 0d 09 09 | 62 72 65 61 6b 3b 0d 09 |imit)...|break;..|
|00003660| 20 20 20 20 20 20 65 6c | 73 65 0d 09 09 63 6f 6e | el|se...con|
|00003670| 74 69 6e 75 65 3b 0d 09 | 20 20 20 20 7d 0d 0d 09 |tinue;..| }...|
|00003680| 20 20 2f 2a 20 50 72 69 | 6e 74 20 6c 65 66 74 6f | /* Pri|nt lefto|
|00003690| 76 65 72 20 6c 69 6e 65 | 73 20 66 72 6f 6d 20 6c |ver line|s from l|
|000036a0| 61 73 74 20 74 69 6d 65 | 2e 20 20 49 66 20 6e 6f |ast time|. If no|
|000036b0| 6e 6d 61 74 63 68 69 6e | 67 5f 6c 69 6e 65 73 20 |nmatchin|g_lines |
|000036c0| 69 73 0d 09 20 20 20 20 | 20 74 75 72 6e 65 64 20 |is.. | turned |
|000036d0| 6f 6e 2c 20 70 72 69 6e | 74 20 74 68 65 73 65 20 |on, prin|t these |
|000036e0| 61 73 20 69 66 20 74 68 | 65 79 20 77 65 72 65 20 |as if th|ey were |
|000036f0| 6d 61 74 63 68 69 6e 67 | 20 6c 69 6e 65 73 2e 20 |matching| lines. |
|00003700| 2a 2f 0d 09 20 20 77 68 | 69 6c 65 20 28 72 65 73 |*/.. wh|ile (res|
|00003710| 75 6d 65 20 3c 20 6d 61 | 74 63 68 69 6e 67 5f 6c |ume < ma|tching_l|
|00003720| 69 6e 65 20 26 26 20 70 | 65 6e 64 69 6e 67 5f 6c |ine && p|ending_l|
|00003730| 69 6e 65 73 29 0d 09 20 | 20 20 20 7b 0d 09 20 20 |ines).. | {.. |
|00003740| 20 20 20 20 72 65 73 75 | 6d 65 20 2b 3d 20 70 72 | resu|me += pr|
|00003750| 69 6e 74 5f 6c 69 6e 65 | 28 72 65 73 75 6d 65 2c |int_line|(resume,|
|00003760| 20 69 6e 69 74 69 61 6c | 5f 6c 69 6e 65 5f 63 6f | initial|_line_co|
|00003770| 75 6e 74 2b 2b 2c 0d 09 | 09 09 09 20 20 20 6e 6f |unt++,..|... no|
|00003780| 6e 6d 61 74 63 68 69 6e | 67 5f 6c 69 6e 65 73 29 |nmatchin|g_lines)|
|00003790| 3b 0d 09 20 20 20 20 20 | 20 2d 2d 70 65 6e 64 69 |;.. | --pendi|
|000037a0| 6e 67 5f 6c 69 6e 65 73 | 3b 0d 09 20 20 20 20 7d |ng_lines|;.. }|
|000037b0| 0d 0d 09 20 20 2f 2a 20 | 50 72 69 6e 74 20 6f 75 |... /* |Print ou|
|000037c0| 74 20 74 68 65 20 6d 61 | 74 63 68 69 6e 67 20 6f |t the ma|tching o|
|000037d0| 72 20 6e 6f 6e 6d 61 74 | 63 68 69 6e 67 20 6c 69 |r nonmat|ching li|
|000037e0| 6e 65 73 20 61 73 20 6e | 65 63 65 73 73 61 72 79 |nes as n|ecessary|
|000037f0| 2e 20 2a 2f 0d 09 20 20 | 69 66 20 28 21 20 6e 6f |. */.. |if (! no|
|00003800| 6e 6d 61 74 63 68 69 6e | 67 5f 6c 69 6e 65 73 29 |nmatchin|g_lines)|
|00003810| 0d 09 20 20 20 20 7b 0d | 09 20 20 20 20 20 20 2f |.. {.|. /|
|00003820| 2a 20 42 61 63 6b 20 75 | 70 20 6f 76 65 72 20 6c |* Back u|p over l|
|00003830| 65 61 64 69 6e 67 20 63 | 6f 6e 74 65 78 74 20 69 |eading c|ontext i|
|00003840| 66 20 6e 65 63 65 73 73 | 61 72 79 2e 20 2a 2f 0d |f necess|ary. */.|
|00003850| 09 20 20 20 20 20 20 66 | 6f 72 20 28 69 20 3d 20 |. f|or (i = |
|00003860| 6c 65 61 64 69 6e 67 5f | 63 6f 6e 74 65 78 74 3b |leading_|context;|
|00003870| 20 6d 61 74 63 68 69 6e | 67 5f 6c 69 6e 65 20 3e | matchin|g_line >|
|00003880| 20 70 72 69 6e 74 65 64 | 5f 6c 69 6d 69 74 0d 09 | printed|_limit..|
|00003890| 09 20 20 20 26 26 20 69 | 3b 20 2d 2d 69 29 0d 09 |. && i|; --i)..|
|000038a0| 09 7b 0d 09 09 20 20 77 | 68 69 6c 65 20 28 6d 61 |.{... w|hile (ma|
|000038b0| 74 63 68 69 6e 67 5f 6c | 69 6e 65 20 3e 20 70 72 |tching_l|ine > pr|
|000038c0| 69 6e 74 65 64 5f 6c 69 | 6d 69 74 0d 09 09 09 20 |inted_li|mit.... |
|000038d0| 26 26 20 28 2d 2d 6d 61 | 74 63 68 69 6e 67 5f 6c |&& (--ma|tching_l|
|000038e0| 69 6e 65 29 5b 2d 31 5d | 20 21 3d 20 27 5c 72 27 |ine)[-1]| != '\r'|
|000038f0| 29 20 20 2f 2a 20 6e 65 | 77 6c 69 6e 65 20 63 68 |) /* ne|wline ch|
|00003900| 61 6e 67 65 64 20 2a 2f | 0d 09 09 20 20 20 20 3b |anged */|... ;|
|00003910| 0d 09 09 20 20 2d 2d 6c | 69 6e 65 5f 63 6f 75 6e |... --l|ine_coun|
|00003920| 74 3b 0d 09 09 7d 0d 0d | 09 20 20 20 20 20 20 2f |t;...}..|. /|
|00003930| 2a 20 49 66 20 63 6f 6e | 74 65 78 74 20 69 73 20 |* If con|text is |
|00003940| 65 6e 61 62 6c 65 64 2c | 20 77 65 20 6d 61 79 20 |enabled,| we may |
|00003950| 68 61 76 65 20 74 6f 20 | 70 72 69 6e 74 20 61 20 |have to |print a |
|00003960| 73 65 70 61 72 61 74 6f | 72 2e 20 2a 2f 0d 09 20 |separato|r. */.. |
|00003970| 20 20 20 20 20 69 66 20 | 28 28 6c 65 61 64 69 6e | if |((leadin|
|00003980| 67 5f 63 6f 6e 74 65 78 | 74 20 7c 7c 20 74 72 61 |g_contex|t || tra|
|00003990| 69 6c 69 6e 67 5f 63 6f | 6e 74 65 78 74 29 20 26 |iling_co|ntext) &|
|000039a0| 26 20 21 73 69 6c 65 6e | 74 0d 09 09 20 20 26 26 |& !silen|t... &&|
|000039b0| 20 21 66 69 72 73 74 5f | 6d 61 74 63 68 20 26 26 | !first_|match &&|
|000039c0| 20 28 70 72 69 6e 74 65 | 64 5f 6c 69 6d 69 74 5f | (printe|d_limit_|
|000039d0| 66 61 6b 65 20 7c 7c 20 | 6d 61 74 63 68 69 6e 67 |fake || |matching|
|000039e0| 5f 6c 69 6e 65 0d 09 09 | 09 09 20 20 20 20 20 20 |_line...|.. |
|000039f0| 3e 20 70 72 69 6e 74 65 | 64 5f 6c 69 6d 69 74 29 |> printe|d_limit)|
|00003a00| 29 0d 09 09 65 6d 69 74 | 64 61 74 61 28 22 2d 2d |)...emit|data("--|
|00003a10| 2d 2d 2d 2d 2d 2d 2d 2d | 5c 72 22 29 3b 0d 09 20 |--------|\r");.. |
|00003a20| 20 20 20 20 20 66 69 72 | 73 74 5f 6d 61 74 63 68 | fir|st_match|
|00003a30| 20 3d 20 30 3b 0d 0d 09 | 20 20 20 20 20 20 2f 2a | = 0;...| /*|
|00003a40| 20 50 72 69 6e 74 20 74 | 68 65 20 6d 61 74 63 68 | Print t|he match|
|00003a50| 69 6e 67 20 6c 69 6e 65 | 20 61 6e 64 20 69 74 73 |ing line| and its|
|00003a60| 20 6c 65 61 64 69 6e 67 | 20 63 6f 6e 74 65 78 74 | leading| context|
|00003a70| 2e 20 2a 2f 0d 09 20 20 | 20 20 20 20 77 68 69 6c |. */.. | whil|
|00003a80| 65 20 28 6d 61 74 63 68 | 69 6e 67 5f 6c 69 6e 65 |e (match|ing_line|
|00003a90| 20 3c 20 72 65 61 6c 5f | 6d 61 74 63 68 69 6e 67 | < real_|matching|
|00003aa0| 5f 6c 69 6e 65 29 0d 09 | 09 6d 61 74 63 68 69 6e |_line)..|.matchin|
|00003ab0| 67 5f 6c 69 6e 65 20 2b | 3d 20 70 72 69 6e 74 5f |g_line +|= print_|
|00003ac0| 6c 69 6e 65 28 6d 61 74 | 63 68 69 6e 67 5f 6c 69 |line(mat|ching_li|
|00003ad0| 6e 65 2c 20 6c 69 6e 65 | 5f 63 6f 75 6e 74 2b 2b |ne, line|_count++|
|00003ae0| 2c 20 30 29 3b 0d 09 20 | 20 20 20 20 20 6d 61 74 |, 0);.. | mat|
|00003af0| 63 68 69 6e 67 5f 6c 69 | 6e 65 20 2b 3d 20 70 72 |ching_li|ne += pr|
|00003b00| 69 6e 74 5f 6c 69 6e 65 | 28 6d 61 74 63 68 69 6e |int_line|(matchin|
|00003b10| 67 5f 6c 69 6e 65 2c 20 | 6c 69 6e 65 5f 63 6f 75 |g_line, |line_cou|
|00003b20| 6e 74 2b 2b 2c 20 31 29 | 3b 0d 0d 09 20 20 20 20 |nt++, 1)|;... |
|00003b30| 20 20 2f 2a 20 49 66 20 | 74 68 65 72 65 27 73 20 | /* If |there's |
|00003b40| 74 72 61 69 6c 69 6e 67 | 20 63 6f 6e 74 65 78 74 |trailing| context|
|00003b50| 2c 20 6c 65 61 76 65 20 | 73 6f 6d 65 20 6c 69 6e |, leave |some lin|
|00003b60| 65 73 20 70 65 6e 64 69 | 6e 67 20 75 6e 74 69 6c |es pendi|ng until|
|00003b70| 0d 09 09 20 6e 65 78 74 | 20 74 69 6d 65 2e 20 2a |... next| time. *|
|00003b80| 2f 0d 09 20 20 20 20 20 | 20 70 65 6e 64 69 6e 67 |/.. | pending|
|00003b90| 5f 6c 69 6e 65 73 20 3d | 20 74 72 61 69 6c 69 6e |_lines =| trailin|
|00003ba0| 67 5f 63 6f 6e 74 65 78 | 74 3b 0d 09 20 20 20 20 |g_contex|t;.. |
|00003bb0| 7d 0d 09 20 20 65 6c 73 | 65 20 69 66 20 28 6d 61 |}.. els|e if (ma|
|00003bc0| 74 63 68 69 6e 67 5f 6c | 69 6e 65 20 3e 20 72 65 |tching_l|ine > re|
|00003bd0| 73 75 6d 65 29 0d 09 20 | 20 20 20 7b 0d 09 20 20 |sume).. | {.. |
|00003be0| 20 20 20 20 63 68 61 72 | 20 2a 72 65 61 6c 5f 72 | char| *real_r|
|00003bf0| 65 73 75 6d 65 20 3d 20 | 72 65 73 75 6d 65 3b 0d |esume = |resume;.|
|00003c00| 0d 09 20 20 20 20 20 20 | 2f 2a 20 42 61 63 6b 20 |.. |/* Back |
|00003c10| 75 70 20 6f 76 65 72 20 | 6c 65 61 64 69 6e 67 20 |up over |leading |
|00003c20| 63 6f 6e 74 65 78 74 20 | 69 66 20 6e 65 63 65 73 |context |if neces|
|00003c30| 73 61 72 79 2e 20 2a 2f | 0d 09 20 20 20 20 20 20 |sary. */|.. |
|00003c40| 66 6f 72 20 28 69 20 3d | 20 6c 65 61 64 69 6e 67 |for (i =| leading|
|00003c50| 5f 63 6f 6e 74 65 78 74 | 3b 20 72 65 73 75 6d 65 |_context|; resume|
|00003c60| 20 3e 20 70 72 69 6e 74 | 65 64 5f 6c 69 6d 69 74 | > print|ed_limit|
|00003c70| 20 26 26 20 69 3b 20 2d | 2d 69 29 0d 09 09 7b 0d | && i; -|-i)...{.|
|00003c80| 09 09 20 20 77 68 69 6c | 65 20 28 72 65 73 75 6d |.. whil|e (resum|
|00003c90| 65 20 3e 20 70 72 69 6e | 74 65 64 5f 6c 69 6d 69 |e > prin|ted_limi|
|00003ca0| 74 20 26 26 20 28 2d 2d | 72 65 73 75 6d 65 29 5b |t && (--|resume)[|
|00003cb0| 2d 31 5d 20 21 3d 20 27 | 5c 72 27 29 20 20 2f 2a |-1] != '|\r') /*|
|00003cc0| 20 6e 65 77 6c 69 6e 65 | 20 63 68 61 6e 67 65 64 | newline| changed|
|00003cd0| 20 2a 2f 0d 09 09 20 20 | 20 20 3b 0d 09 09 20 20 | */... | ;... |
|00003ce0| 2d 2d 69 6e 69 74 69 61 | 6c 5f 6c 69 6e 65 5f 63 |--initia|l_line_c|
|00003cf0| 6f 75 6e 74 3b 0d 09 09 | 7d 0d 0d 09 20 20 20 20 |ount;...|}... |
|00003d00| 20 20 2f 2a 20 49 66 20 | 63 6f 6e 74 65 78 74 20 | /* If |context |
|00003d10| 69 73 20 65 6e 61 62 6c | 65 64 2c 20 77 65 20 6d |is enabl|ed, we m|
|00003d20| 61 79 20 68 61 76 65 20 | 74 6f 20 70 72 69 6e 74 |ay have |to print|
|00003d30| 20 61 20 73 65 70 61 72 | 61 74 6f 72 2e 20 2a 2f | a separ|ator. */|
|00003d40| 0d 09 20 20 20 20 20 20 | 69 66 20 28 28 6c 65 61 |.. |if ((lea|
|00003d50| 64 69 6e 67 5f 63 6f 6e | 74 65 78 74 20 7c 7c 20 |ding_con|text || |
|00003d60| 74 72 61 69 6c 69 6e 67 | 5f 63 6f 6e 74 65 78 74 |trailing|_context|
|00003d70| 29 20 26 26 20 21 73 69 | 6c 65 6e 74 0d 09 09 20 |) && !si|lent... |
|00003d80| 20 26 26 20 21 66 69 72 | 73 74 5f 6d 61 74 63 68 | && !fir|st_match|
|00003d90| 20 26 26 20 28 70 72 69 | 6e 74 65 64 5f 6c 69 6d | && (pri|nted_lim|
|00003da0| 69 74 5f 66 61 6b 65 20 | 7c 7c 20 72 65 73 75 6d |it_fake ||| resum|
|00003db0| 65 0d 09 09 09 09 20 20 | 20 20 20 20 3e 20 70 72 |e..... | > pr|
|00003dc0| 69 6e 74 65 64 5f 6c 69 | 6d 69 74 29 29 0d 09 09 |inted_li|mit))...|
|00003dd0| 65 6d 69 74 64 61 74 61 | 28 22 2d 2d 2d 2d 2d 2d |emitdata|("------|
|00003de0| 2d 2d 2d 2d 5c 72 22 29 | 3b 0d 09 20 20 20 20 20 |----\r")|;.. |
|00003df0| 20 66 69 72 73 74 5f 6d | 61 74 63 68 20 3d 20 30 | first_m|atch = 0|
|00003e00| 3b 0d 0d 09 20 20 20 20 | 20 20 2f 2a 20 50 72 69 |;... | /* Pri|
|00003e10| 6e 74 20 6f 75 74 20 74 | 68 65 20 70 72 65 73 75 |nt out t|he presu|
|00003e20| 6d 61 62 6c 79 20 6d 61 | 74 63 68 69 6e 67 20 6c |mably ma|tching l|
|00003e30| 65 61 64 69 6e 67 20 63 | 6f 6e 74 65 78 74 2e 20 |eading c|ontext. |
|00003e40| 2a 2f 0d 09 20 20 20 20 | 20 20 77 68 69 6c 65 20 |*/.. | while |
|00003e50| 28 72 65 73 75 6d 65 20 | 3c 20 72 65 61 6c 5f 72 |(resume |< real_r|
|00003e60| 65 73 75 6d 65 29 0d 09 | 09 72 65 73 75 6d 65 20 |esume)..|.resume |
|00003e70| 2b 3d 20 70 72 69 6e 74 | 5f 6c 69 6e 65 28 72 65 |+= print|_line(re|
|00003e80| 73 75 6d 65 2c 20 69 6e | 69 74 69 61 6c 5f 6c 69 |sume, in|itial_li|
|00003e90| 6e 65 5f 63 6f 75 6e 74 | 2b 2b 2c 20 30 29 3b 0d |ne_count|++, 0);.|
|00003ea0| 0d 09 20 20 20 20 20 20 | 2f 2a 20 50 72 69 6e 74 |.. |/* Print|
|00003eb0| 20 6f 75 74 20 74 68 65 | 20 6e 6f 6e 6d 61 74 63 | out the| nonmatc|
|00003ec0| 68 69 6e 67 20 6c 69 6e | 65 73 20 70 72 69 6f 72 |hing lin|es prior|
|00003ed0| 20 74 6f 20 74 68 65 20 | 6d 61 74 63 68 69 6e 67 | to the |matching|
|00003ee0| 20 6c 69 6e 65 2e 20 2a | 2f 0d 09 20 20 20 20 20 | line. *|/.. |
|00003ef0| 20 77 68 69 6c 65 20 28 | 72 65 73 75 6d 65 20 3c | while (|resume <|
|00003f00| 20 6d 61 74 63 68 69 6e | 67 5f 6c 69 6e 65 29 0d | matchin|g_line).|
|00003f10| 09 09 72 65 73 75 6d 65 | 20 2b 3d 20 70 72 69 6e |..resume| += prin|
|00003f20| 74 5f 6c 69 6e 65 28 72 | 65 73 75 6d 65 2c 20 69 |t_line(r|esume, i|
|00003f30| 6e 69 74 69 61 6c 5f 6c | 69 6e 65 5f 63 6f 75 6e |nitial_l|ine_coun|
|00003f40| 74 2b 2b 2c 20 31 29 3b | 0d 0d 09 20 20 20 20 20 |t++, 1);|... |
|00003f50| 20 2f 2a 20 44 65 61 6c | 20 77 69 74 68 20 74 72 | /* Deal| with tr|
|00003f60| 61 69 6c 69 6e 67 20 63 | 6f 6e 74 65 78 74 2e 20 |ailing c|ontext. |
|00003f70| 2a 2f 0d 09 20 20 20 20 | 20 20 69 66 20 28 74 72 |*/.. | if (tr|
|00003f80| 61 69 6c 69 6e 67 5f 63 | 6f 6e 74 65 78 74 29 0d |ailing_c|ontext).|
|00003f90| 09 09 7b 0d 09 09 20 20 | 70 72 69 6e 74 5f 6c 69 |..{... |print_li|
|00003fa0| 6e 65 28 6d 61 74 63 68 | 69 6e 67 5f 6c 69 6e 65 |ne(match|ing_line|
|00003fb0| 2c 20 6c 69 6e 65 5f 63 | 6f 75 6e 74 2c 20 30 29 |, line_c|ount, 0)|
|00003fc0| 3b 0d 09 09 20 20 70 65 | 6e 64 69 6e 67 5f 6c 69 |;... pe|nding_li|
|00003fd0| 6e 65 73 20 3d 20 74 72 | 61 69 6c 69 6e 67 5f 63 |nes = tr|ailing_c|
|00003fe0| 6f 6e 74 65 78 74 20 2d | 20 31 3b 0d 09 09 7d 0d |ontext -| 1;...}.|
|00003ff0| 0d 09 20 20 20 20 20 20 | 2f 2a 20 43 6f 75 6e 74 |.. |/* Count|
|00004000| 20 74 68 65 20 63 75 72 | 72 65 6e 74 20 6c 69 6e | the cur|rent lin|
|00004010| 65 2e 20 2a 2f 0d 09 20 | 20 20 20 20 20 2b 2b 6c |e. */.. | ++l|
|00004020| 69 6e 65 5f 63 6f 75 6e | 74 3b 0d 09 20 20 20 20 |ine_coun|t;.. |
|00004030| 7d 0d 09 20 20 65 6c 73 | 65 0d 09 20 20 20 20 7b |}.. els|e.. {|
|00004040| 0d 09 20 20 20 20 20 20 | 2f 2a 20 54 68 65 20 6c |.. |/* The l|
|00004050| 69 6e 65 20 69 6d 6d 65 | 64 69 61 74 65 6c 79 20 |ine imme|diately |
|00004060| 61 66 74 65 72 20 61 20 | 6d 61 74 63 68 69 6e 67 |after a |matching|
|00004070| 20 6c 69 6e 65 20 68 61 | 73 20 74 6f 20 62 65 20 | line ha|s to be |
|00004080| 70 72 69 6e 74 65 64 0d | 09 09 20 62 65 63 61 75 |printed.|.. becau|
|00004090| 73 65 20 69 74 20 77 61 | 73 20 70 65 6e 64 69 6e |se it wa|s pendin|
|000040a0| 67 2e 20 2a 2f 0d 09 20 | 20 20 20 20 20 69 66 20 |g. */.. | if |
|000040b0| 28 70 65 6e 64 69 6e 67 | 5f 6c 69 6e 65 73 20 3e |(pending|_lines >|
|000040c0| 20 30 29 0d 09 09 7b 0d | 09 09 20 20 2d 2d 70 65 | 0)...{.|.. --pe|
|000040d0| 6e 64 69 6e 67 5f 6c 69 | 6e 65 73 3b 0d 09 09 20 |nding_li|nes;... |
|000040e0| 20 70 72 69 6e 74 5f 6c | 69 6e 65 28 6d 61 74 63 | print_l|ine(matc|
|000040f0| 68 69 6e 67 5f 6c 69 6e | 65 2c 20 6c 69 6e 65 5f |hing_lin|e, line_|
|00004100| 63 6f 75 6e 74 2c 20 30 | 29 3b 0d 09 09 7d 0d 09 |count, 0|);...}..|
|00004110| 20 20 20 20 20 20 2b 2b | 6c 69 6e 65 5f 63 6f 75 | ++|line_cou|
|00004120| 6e 74 3b 0d 09 20 20 20 | 20 7d 0d 0d 09 20 20 2f |nt;.. | }... /|
|00004130| 2a 20 52 65 73 75 6d 65 | 20 73 65 61 72 63 68 69 |* Resume| searchi|
|00004140| 6e 67 20 61 74 20 74 68 | 65 20 62 65 67 69 6e 6e |ng at th|e beginn|
|00004150| 69 6e 67 20 6f 66 20 74 | 68 65 20 6e 65 78 74 20 |ing of t|he next |
|00004160| 6c 69 6e 65 2e 20 2a 2f | 0d 09 20 20 69 6e 69 74 |line. */|.. init|
|00004170| 69 61 6c 5f 6c 69 6e 65 | 5f 63 6f 75 6e 74 20 3d |ial_line|_count =|
|00004180| 20 6c 69 6e 65 5f 63 6f | 75 6e 74 3b 0d 09 20 20 | line_co|unt;.. |
|00004190| 72 65 73 75 6d 65 20 3d | 20 6e 65 78 74 5f 6c 69 |resume =| next_li|
|000041a0| 6e 65 3b 0d 0d 09 20 20 | 69 66 20 28 72 65 73 75 |ne;... |if (resu|
|000041b0| 6d 65 20 3d 3d 20 73 65 | 61 72 63 68 5f 6c 69 6d |me == se|arch_lim|
|000041c0| 69 74 29 0d 09 20 20 20 | 20 62 72 65 61 6b 3b 0d |it).. | break;.|
|000041d0| 09 7d 0d 20 0d 20 20 20 | 20 20 20 2f 2a 20 52 65 |.}. . | /* Re|
|000041e0| 73 74 6f 72 65 20 74 68 | 65 20 73 61 76 65 64 20 |store th|e saved |
|000041f0| 63 68 61 72 61 63 74 65 | 72 2e 20 2a 2f 0d 20 20 |characte|r. */. |
|00004200| 20 20 20 20 2a 73 65 61 | 72 63 68 5f 6c 69 6d 69 | *sea|rch_limi|
|00004210| 74 20 3d 20 73 61 76 65 | 64 5f 63 68 61 72 3b 0d |t = save|d_char;.|
|00004220| 0d 20 20 20 20 20 20 69 | 66 20 28 21 20 6e 6f 6e |. i|f (! non|
|00004230| 6d 61 74 63 68 69 6e 67 | 5f 6c 69 6e 65 73 29 0d |matching|_lines).|
|00004240| 09 7b 0d 09 20 20 77 68 | 69 6c 65 20 28 72 65 73 |.{.. wh|ile (res|
|00004250| 75 6d 65 20 3c 20 73 65 | 61 72 63 68 5f 6c 69 6d |ume < se|arch_lim|
|00004260| 69 74 20 26 26 20 70 65 | 6e 64 69 6e 67 5f 6c 69 |it && pe|nding_li|
|00004270| 6e 65 73 29 0d 09 20 20 | 20 20 7b 0d 09 20 20 20 |nes).. | {.. |
|00004280| 20 20 20 72 65 73 75 6d | 65 20 2b 3d 20 70 72 69 | resum|e += pri|
|00004290| 6e 74 5f 6c 69 6e 65 28 | 72 65 73 75 6d 65 2c 20 |nt_line(|resume, |
|000042a0| 69 6e 69 74 69 61 6c 5f | 6c 69 6e 65 5f 63 6f 75 |initial_|line_cou|
|000042b0| 6e 74 2b 2b 2c 20 30 29 | 3b 0d 09 20 20 20 20 20 |nt++, 0)|;.. |
|000042c0| 20 2d 2d 70 65 6e 64 69 | 6e 67 5f 6c 69 6e 65 73 | --pendi|ng_lines|
|000042d0| 3b 0d 09 20 20 20 20 7d | 0d 09 7d 0d 20 20 20 20 |;.. }|..}. |
|000042e0| 20 20 65 6c 73 65 20 69 | 66 20 28 73 65 61 72 63 | else i|f (searc|
|000042f0| 68 5f 6c 69 6d 69 74 20 | 3e 20 72 65 73 75 6d 65 |h_limit |> resume|
|00004300| 29 0d 09 7b 0d 09 20 20 | 63 68 61 72 20 2a 69 6e |)..{.. |char *in|
|00004310| 69 74 69 61 6c 5f 72 65 | 73 75 6d 65 20 3d 20 72 |itial_re|sume = r|
|00004320| 65 73 75 6d 65 3b 0d 0d | 09 20 20 2f 2a 20 42 61 |esume;..|. /* Ba|
|00004330| 63 6b 20 75 70 20 6f 76 | 65 72 20 6c 65 61 64 69 |ck up ov|er leadi|
|00004340| 6e 67 20 63 6f 6e 74 65 | 78 74 20 69 66 20 6e 65 |ng conte|xt if ne|
|00004350| 63 65 73 73 61 72 79 2e | 20 2a 2f 0d 09 20 20 66 |cessary.| */.. f|
|00004360| 6f 72 20 28 69 20 3d 20 | 6c 65 61 64 69 6e 67 5f |or (i = |leading_|
|00004370| 63 6f 6e 74 65 78 74 3b | 20 72 65 73 75 6d 65 20 |context;| resume |
|00004380| 3e 20 70 72 69 6e 74 65 | 64 5f 6c 69 6d 69 74 20 |> printe|d_limit |
|00004390| 26 26 20 69 3b 20 2d 2d | 69 29 0d 09 20 20 20 20 |&& i; --|i).. |
|000043a0| 7b 0d 09 20 20 20 20 20 | 20 77 68 69 6c 65 20 28 |{.. | while (|
|000043b0| 72 65 73 75 6d 65 20 3e | 20 70 72 69 6e 74 65 64 |resume >| printed|
|000043c0| 5f 6c 69 6d 69 74 20 26 | 26 20 28 2d 2d 72 65 73 |_limit &|& (--res|
|000043d0| 75 6d 65 29 5b 2d 31 5d | 20 21 3d 20 27 5c 72 27 |ume)[-1]| != '\r'|
|000043e0| 29 20 20 2f 2a 20 6e 65 | 77 6c 69 6e 65 20 63 68 |) /* ne|wline ch|
|000043f0| 61 6e 67 65 64 20 2a 2f | 0d 09 09 3b 0d 09 20 20 |anged */|...;.. |
|00004400| 20 20 20 20 2d 2d 69 6e | 69 74 69 61 6c 5f 6c 69 | --in|itial_li|
|00004410| 6e 65 5f 63 6f 75 6e 74 | 3b 0d 09 20 20 20 20 7d |ne_count|;.. }|
|00004420| 0d 0d 09 20 20 2f 2a 20 | 49 66 20 63 6f 6e 74 65 |... /* |If conte|
|00004430| 78 74 20 69 73 20 65 6e | 61 62 6c 65 64 2c 20 77 |xt is en|abled, w|
|00004440| 65 20 6d 61 79 20 68 61 | 76 65 20 74 6f 20 70 72 |e may ha|ve to pr|
|00004450| 69 6e 74 20 61 20 73 65 | 70 61 72 61 74 6f 72 2e |int a se|parator.|
|00004460| 20 2a 2f 0d 09 20 20 69 | 66 20 28 28 6c 65 61 64 | */.. i|f ((lead|
|00004470| 69 6e 67 5f 63 6f 6e 74 | 65 78 74 20 7c 7c 20 74 |ing_cont|ext || t|
|00004480| 72 61 69 6c 69 6e 67 5f | 63 6f 6e 74 65 78 74 29 |railing_|context)|
|00004490| 20 26 26 20 21 73 69 6c | 65 6e 74 0d 09 20 20 20 | && !sil|ent.. |
|000044a0| 20 20 20 26 26 20 21 66 | 69 72 73 74 5f 6d 61 74 | && !f|irst_mat|
|000044b0| 63 68 20 26 26 20 28 70 | 72 69 6e 74 65 64 5f 6c |ch && (p|rinted_l|
|000044c0| 69 6d 69 74 5f 66 61 6b | 65 20 7c 7c 20 72 65 73 |imit_fak|e || res|
|000044d0| 75 6d 65 0d 09 09 09 09 | 20 20 3e 20 70 72 69 6e |ume.....| > prin|
|000044e0| 74 65 64 5f 6c 69 6d 69 | 74 29 29 0d 09 20 20 20 |ted_limi|t)).. |
|000044f0| 20 65 6d 69 74 64 61 74 | 61 28 22 2d 2d 2d 2d 2d | emitdat|a("-----|
|00004500| 2d 2d 2d 2d 2d 5c 72 22 | 29 3b 0d 09 20 20 66 69 |-----\r"|);.. fi|
|00004510| 72 73 74 5f 6d 61 74 63 | 68 20 3d 20 30 3b 0d 0d |rst_matc|h = 0;..|
|00004520| 09 20 20 2f 2a 20 50 72 | 69 6e 74 20 6f 75 74 20 |. /* Pr|int out |
|00004530| 61 6c 6c 20 74 68 65 20 | 6e 6f 6e 6d 61 74 63 68 |all the |nonmatch|
|00004540| 69 6e 67 20 6c 69 6e 65 | 73 20 75 70 20 74 6f 20 |ing line|s up to |
|00004550| 74 68 65 20 73 65 61 72 | 63 68 20 6c 69 6d 69 74 |the sear|ch limit|
|00004560| 2e 20 2a 2f 0d 09 20 20 | 77 68 69 6c 65 20 28 72 |. */.. |while (r|
|00004570| 65 73 75 6d 65 20 3c 20 | 69 6e 69 74 69 61 6c 5f |esume < |initial_|
|00004580| 72 65 73 75 6d 65 29 0d | 09 20 20 20 20 72 65 73 |resume).|. res|
|00004590| 75 6d 65 20 2b 3d 20 70 | 72 69 6e 74 5f 6c 69 6e |ume += p|rint_lin|
|000045a0| 65 28 72 65 73 75 6d 65 | 2c 20 69 6e 69 74 69 61 |e(resume|, initia|
|000045b0| 6c 5f 6c 69 6e 65 5f 63 | 6f 75 6e 74 2b 2b 2c 20 |l_line_c|ount++, |
|000045c0| 30 29 3b 0d 09 20 20 77 | 68 69 6c 65 20 28 72 65 |0);.. w|hile (re|
|000045d0| 73 75 6d 65 20 3c 20 73 | 65 61 72 63 68 5f 6c 69 |sume < s|earch_li|
|000045e0| 6d 69 74 29 0d 09 20 20 | 20 20 72 65 73 75 6d 65 |mit).. | resume|
|000045f0| 20 2b 3d 20 70 72 69 6e | 74 5f 6c 69 6e 65 28 72 | += prin|t_line(r|
|00004600| 65 73 75 6d 65 2c 20 69 | 6e 69 74 69 61 6c 5f 6c |esume, i|nitial_l|
|00004610| 69 6e 65 5f 63 6f 75 6e | 74 2b 2b 2c 20 31 29 3b |ine_coun|t++, 1);|
|00004620| 0d 0d 09 20 20 70 65 6e | 64 69 6e 67 5f 6c 69 6e |... pen|ding_lin|
|00004630| 65 73 20 3d 20 74 72 61 | 69 6c 69 6e 67 5f 63 6f |es = tra|iling_co|
|00004640| 6e 74 65 78 74 3b 0d 09 | 20 20 72 65 73 75 6d 65 |ntext;..| resume|
|00004650| 5f 69 6e 64 65 78 20 3d | 20 30 3b 0d 09 20 20 72 |_index =| 0;.. r|
|00004660| 65 74 61 69 6e 20 3d 20 | 62 75 66 62 79 74 65 73 |etain = |bufbytes|
|00004670| 20 2d 20 28 73 65 61 72 | 63 68 5f 6c 69 6d 69 74 | - (sear|ch_limit|
|00004680| 20 2d 20 62 75 66 66 65 | 72 29 3b 0d 09 20 20 63 | - buffe|r);.. c|
|00004690| 6f 6e 74 69 6e 75 65 3b | 0d 09 7d 0d 20 20 20 20 |ontinue;|..}. |
|000046a0| 20 20 0d 20 20 20 20 20 | 20 2f 2a 20 53 61 76 65 | . | /* Save|
|000046b0| 20 74 68 65 20 74 72 61 | 69 6c 69 6e 67 20 65 6e | the tra|iling en|
|000046c0| 64 20 6f 66 20 74 68 65 | 20 62 75 66 66 65 72 20 |d of the| buffer |
|000046d0| 66 6f 72 20 70 6f 73 73 | 69 62 6c 65 20 75 73 65 |for poss|ible use|
|000046e0| 20 61 73 20 6c 65 61 64 | 69 6e 67 0d 09 20 63 6f | as lead|ing.. co|
|000046f0| 6e 74 65 78 74 20 69 6e | 20 74 68 65 20 66 75 74 |ntext in| the fut|
|00004700| 75 72 65 2e 20 2a 2f 0d | 20 20 20 20 20 20 69 20 |ure. */.| i |
|00004710| 3d 20 6c 65 61 64 69 6e | 67 5f 63 6f 6e 74 65 78 |= leadin|g_contex|
|00004720| 74 3b 0d 20 20 20 20 20 | 20 74 6d 70 20 3d 20 73 |t;. | tmp = s|
|00004730| 65 61 72 63 68 5f 6c 69 | 6d 69 74 3b 0d 20 20 20 |earch_li|mit;. |
|00004740| 20 20 20 77 68 69 6c 65 | 20 28 74 6d 70 20 3e 20 | while| (tmp > |
|00004750| 70 72 69 6e 74 65 64 5f | 6c 69 6d 69 74 20 26 26 |printed_|limit &&|
|00004760| 20 69 2d 2d 29 0d 09 77 | 68 69 6c 65 20 28 74 6d | i--)..w|hile (tm|
|00004770| 70 20 3e 20 70 72 69 6e | 74 65 64 5f 6c 69 6d 69 |p > prin|ted_limi|
|00004780| 74 20 26 26 20 28 2d 2d | 74 6d 70 29 5b 2d 31 5d |t && (--|tmp)[-1]|
|00004790| 20 21 3d 20 27 5c 72 27 | 29 20 20 2f 2a 20 6e 65 | != '\r'|) /* ne|
|000047a0| 77 6c 69 6e 65 20 63 68 | 61 6e 67 65 64 20 2a 2f |wline ch|anged */|
|000047b0| 0d 09 20 20 3b 0d 20 20 | 20 20 20 20 72 65 73 75 |.. ;. | resu|
|000047c0| 6d 65 5f 69 6e 64 65 78 | 20 3d 20 73 65 61 72 63 |me_index| = searc|
|000047d0| 68 5f 6c 69 6d 69 74 20 | 2d 20 74 6d 70 3b 0d 20 |h_limit |- tmp;. |
|000047e0| 20 20 20 20 20 72 65 74 | 61 69 6e 20 3d 20 62 75 | ret|ain = bu|
|000047f0| 66 62 79 74 65 73 20 2d | 20 28 74 6d 70 20 2d 20 |fbytes -| (tmp - |
|00004800| 62 75 66 66 65 72 29 3b | 0d 20 20 20 20 20 20 69 |buffer);|. i|
|00004810| 66 20 28 74 6d 70 20 3e | 20 70 72 69 6e 74 65 64 |f (tmp >| printed|
|00004820| 5f 6c 69 6d 69 74 29 0d | 09 70 72 69 6e 74 65 64 |_limit).|.printed|
|00004830| 5f 6c 69 6d 69 74 5f 66 | 61 6b 65 20 3d 20 31 3b |_limit_f|ake = 1;|
|00004840| 0d 20 20 20 20 7d 0d 0d | 20 20 72 65 74 75 72 6e |. }..| return|
|00004850| 20 6e 6f 6e 6d 61 74 63 | 68 69 6e 67 5f 6c 69 6e | nonmatc|hing_lin|
|00004860| 65 73 20 3f 20 28 6c 69 | 6e 65 5f 63 6f 75 6e 74 |es ? (li|ne_count|
|00004870| 20 2d 20 31 29 20 2d 20 | 6d 61 74 63 68 5f 63 6f | - 1) - |match_co|
|00004880| 75 6e 74 20 3a 20 6d 61 | 74 63 68 5f 63 6f 75 6e |unt : ma|tch_coun|
|00004890| 74 3b 0d 7d 0d 0d 0d 0d | 2f 2a 0d 20 20 20 62 6d |t;.}....|/*. bm|
|000048a0| 67 5f 73 65 74 75 70 28 | 29 20 61 6e 64 20 62 6d |g_setup(|) and bm|
|000048b0| 67 5f 73 65 61 72 63 68 | 28 29 20 61 64 61 70 74 |g_search|() adapt|
|000048c0| 65 64 20 66 72 6f 6d 3a | 0d 20 20 20 20 20 42 6f |ed from:|. Bo|
|000048d0| 79 65 72 2f 4d 6f 6f 72 | 65 2f 47 6f 73 70 65 72 |yer/Moor|e/Gosper|
|000048e0| 2d 61 73 73 69 73 74 65 | 64 20 27 65 67 72 65 70 |-assiste|d 'egrep|
|000048f0| 27 20 73 65 61 72 63 68 | 2c 20 77 69 74 68 20 64 |' search|, with d|
|00004900| 65 6c 74 61 30 20 74 61 | 62 6c 65 20 61 73 20 69 |elta0 ta|ble as i|
|00004910| 6e 0d 20 20 20 20 20 6f | 72 69 67 69 6e 61 6c 20 |n. o|riginal |
|00004920| 70 61 70 65 72 20 28 43 | 41 43 4d 2c 20 4f 63 74 |paper (C|ACM, Oct|
|00004930| 6f 62 65 72 2c 20 31 39 | 37 37 29 2e 20 20 4e 6f |ober, 19|77). No|
|00004940| 20 64 65 6c 74 61 31 20 | 6f 72 20 64 65 6c 74 61 | delta1 |or delta|
|00004950| 32 2e 20 20 41 63 63 6f | 72 64 69 6e 67 20 74 6f |2. Acco|rding to|
|00004960| 0d 20 20 20 20 20 65 78 | 70 65 72 69 6d 65 6e 74 |. ex|periment|
|00004970| 20 28 48 6f 72 73 70 6f | 6f 6c 2c 20 53 6f 66 74 | (Horspo|ol, Soft|
|00004980| 2e 20 50 72 61 63 2e 20 | 45 78 70 2e 2c 20 31 39 |. Prac. |Exp., 19|
|00004990| 38 32 29 2c 20 64 65 6c | 74 61 32 20 69 73 20 6f |82), del|ta2 is o|
|000049a0| 66 20 6d 69 6e 69 6d 61 | 6c 0d 20 20 20 20 20 70 |f minima|l. p|
|000049b0| 72 61 63 74 69 63 61 6c | 20 76 61 6c 75 65 2e 20 |ractical| value. |
|000049c0| 20 48 6f 77 65 76 65 72 | 2c 20 74 6f 20 69 6d 70 | However|, to imp|
|000049d0| 72 6f 76 65 20 66 6f 72 | 20 77 6f 72 73 74 20 63 |rove for| worst c|
|000049e0| 61 73 65 20 69 6e 70 75 | 74 2c 20 69 6e 74 65 67 |ase inpu|t, integ|
|000049f0| 72 61 74 69 6e 67 0d 20 | 20 20 20 20 74 68 65 20 |rating. | the |
|00004a00| 69 6d 70 72 6f 76 65 64 | 20 47 61 6c 69 6c 20 73 |improved| Galil s|
|00004a10| 74 72 61 74 65 67 69 65 | 73 20 28 41 70 6f 73 74 |trategie|s (Apost|
|00004a20| 6f 6c 69 63 6f 2f 47 69 | 61 6e 63 61 72 6c 6f 2c |olico/Gi|ancarlo,|
|00004a30| 20 53 69 61 6d 2e 20 4a | 2e 20 43 6f 6d 70 75 74 | Siam. J|. Comput|
|00004a40| 2e 2c 0d 20 20 20 20 20 | 46 65 62 72 75 61 72 79 |.,. |February|
|00004a50| 20 31 39 38 36 29 20 64 | 65 73 65 72 76 65 73 20 | 1986) d|eserves |
|00004a60| 63 6f 6e 73 69 64 65 72 | 61 74 69 6f 6e 2e 0d 0d |consider|ation...|
|00004a70| 20 20 20 20 20 4a 61 6d | 65 73 20 41 2e 20 57 6f | Jam|es A. Wo|
|00004a80| 6f 64 73 09 09 09 09 43 | 6f 70 79 6c 65 66 74 20 |ods....C|opyleft |
|00004a90| 28 43 29 20 31 39 38 36 | 2c 20 31 39 38 38 0d 20 |(C) 1986|, 1988. |
|00004aa0| 20 20 20 20 4e 41 53 41 | 20 41 6d 65 73 20 52 65 | NASA| Ames Re|
|00004ab0| 73 65 61 72 63 68 20 43 | 65 6e 74 65 72 0d 2a 2f |search C|enter.*/|
|00004ac0| 0d 0d 63 68 61 72 20 2a | 0d 65 78 65 63 75 74 65 |..char *|.execute|
|00004ad0| 28 72 2c 20 62 65 67 69 | 6e 2c 20 65 6e 64 2c 20 |(r, begi|n, end, |
|00004ae0| 6e 65 77 6c 69 6e 65 2c | 20 63 6f 75 6e 74 2c 20 |newline,| count, |
|00004af0| 74 72 79 5f 62 61 63 6b | 72 65 66 29 0d 20 20 73 |try_back|ref). s|
|00004b00| 74 72 75 63 74 20 72 65 | 67 65 78 70 20 2a 72 3b |truct re|gexp *r;|
|00004b10| 0d 20 20 63 68 61 72 20 | 2a 62 65 67 69 6e 3b 0d |. char |*begin;.|
|00004b20| 20 20 63 68 61 72 20 2a | 65 6e 64 3b 0d 20 20 69 | char *|end;. i|
|00004b30| 6e 74 20 6e 65 77 6c 69 | 6e 65 3b 0d 20 20 69 6e |nt newli|ne;. in|
|00004b40| 74 20 2a 63 6f 75 6e 74 | 3b 0d 20 20 69 6e 74 20 |t *count|;. int |
|00004b50| 2a 74 72 79 5f 62 61 63 | 6b 72 65 66 3b 0d 7b 0d |*try_bac|kref;.{.|
|00004b60| 20 20 72 65 67 69 73 74 | 65 72 20 63 68 61 72 20 | regist|er char |
|00004b70| 2a 70 2c 20 2a 73 3b 0d | 20 20 63 68 61 72 20 2a |*p, *s;.| char *|
|00004b80| 6d 61 74 63 68 3b 0d 20 | 20 63 68 61 72 20 2a 73 |match;. | char *s|
|00004b90| 74 61 72 74 20 3d 20 62 | 65 67 69 6e 3b 0d 20 20 |tart = b|egin;. |
|00004ba0| 63 68 61 72 20 73 61 76 | 65 3b 09 09 09 2f 2a 20 |char sav|e;.../* |
|00004bb0| 72 65 67 65 78 65 63 75 | 74 65 28 29 20 73 65 6e |regexecu|te() sen|
|00004bc0| 74 69 6e 65 6c 20 2a 2f | 0d 20 20 69 6e 74 20 6c |tinel */|. int l|
|00004bd0| 65 6e 3b 0d 20 20 63 68 | 61 72 20 2a 62 6d 67 5f |en;. ch|ar *bmg_|
|00004be0| 73 65 61 72 63 68 28 29 | 3b 0d 0d 20 20 69 66 20 |search()|;.. if |
|00004bf0| 28 21 62 6d 67 65 78 65 | 63 29 09 09 09 2f 2a 20 |(!bmgexe|c).../* |
|00004c00| 66 75 6c 6c 20 61 75 74 | 6f 6d 61 74 6f 6e 20 73 |full aut|omaton s|
|00004c10| 65 61 72 63 68 20 2a 2f | 0d 20 20 20 20 72 65 74 |earch */|. ret|
|00004c20| 75 72 6e 28 72 65 67 65 | 78 65 63 75 74 65 28 72 |urn(rege|xecute(r|
|00004c30| 2c 20 62 65 67 69 6e 2c | 20 65 6e 64 2c 20 6e 65 |, begin,| end, ne|
|00004c40| 77 6c 69 6e 65 2c 20 63 | 6f 75 6e 74 2c 20 74 72 |wline, c|ount, tr|
|00004c50| 79 5f 62 61 63 6b 72 65 | 66 29 29 3b 0d 20 20 65 |y_backre|f));. e|
|00004c60| 6c 73 65 0d 20 20 20 20 | 7b 0d 20 20 20 20 20 20 |lse. |{. |
|00004c70| 6c 65 6e 20 3d 20 65 6e | 64 20 2d 20 62 65 67 69 |len = en|d - begi|
|00004c80| 6e 3b 20 0d 20 20 20 20 | 20 20 77 68 69 6c 65 20 |n; . | while |
|00004c90| 28 28 6d 61 74 63 68 20 | 3d 20 62 6d 67 5f 73 65 |((match |= bmg_se|
|00004ca0| 61 72 63 68 28 28 75 6e | 73 69 67 6e 65 64 20 63 |arch((un|signed c|
|00004cb0| 68 61 72 20 2a 29 20 73 | 74 61 72 74 2c 20 6c 65 |har *) s|tart, le|
|00004cc0| 6e 29 29 20 21 3d 20 4e | 55 4c 4c 29 0d 09 7b 0d |n)) != N|ULL)..{.|
|00004cd0| 09 20 20 70 20 3d 20 6d | 61 74 63 68 3b 09 09 2f |. p = m|atch;../|
|00004ce0| 2a 20 6e 61 72 72 6f 77 | 20 73 65 61 72 63 68 20 |* narrow| search |
|00004cf0| 72 61 6e 67 65 20 74 6f | 20 73 75 62 6d 61 74 63 |range to| submatc|
|00004d00| 68 20 6c 69 6e 65 20 2a | 2f 0d 09 20 20 77 68 69 |h line *|/.. whi|
|00004d10| 6c 65 20 28 70 20 3e 20 | 62 65 67 69 6e 20 26 26 |le (p > |begin &&|
|00004d20| 20 2a 70 20 21 3d 20 27 | 5c 72 27 29 20 20 2f 2a | *p != '|\r') /*|
|00004d30| 20 6e 65 77 6c 69 6e 65 | 20 63 68 61 6e 67 65 64 | newline| changed|
|00004d40| 20 2a 2f 0d 09 20 20 20 | 20 70 2d 2d 3b 0d 09 20 | */.. | p--;.. |
|00004d50| 20 73 20 3d 20 6d 61 74 | 63 68 3b 0d 09 20 20 77 | s = mat|ch;.. w|
|00004d60| 68 69 6c 65 20 28 73 20 | 3c 20 65 6e 64 20 26 26 |hile (s |< end &&|
|00004d70| 20 2a 73 20 21 3d 20 27 | 5c 72 27 29 20 20 2f 2a | *s != '|\r') /*|
|00004d80| 20 6e 65 77 6c 69 6e 65 | 20 63 68 61 6e 67 65 64 | newline| changed|
|00004d90| 20 2a 2f 0d 09 20 20 20 | 20 73 2b 2b 3b 0d 09 20 | */.. | s++;.. |
|00004da0| 20 73 2b 2b 3b 0d 0d 09 | 20 20 73 61 76 65 20 3d | s++;...| save =|
|00004db0| 20 2a 73 3b 0d 09 20 20 | 2a 73 20 3d 20 27 5c 30 | *s;.. |*s = '\0|
|00004dc0| 27 3b 0d 09 20 20 6d 61 | 74 63 68 20 3d 20 72 65 |';.. ma|tch = re|
|00004dd0| 67 65 78 65 63 75 74 65 | 28 72 2c 20 70 2c 20 73 |gexecute|(r, p, s|
|00004de0| 2c 20 6e 65 77 6c 69 6e | 65 2c 20 63 6f 75 6e 74 |, newlin|e, count|
|00004df0| 2c 20 74 72 79 5f 62 61 | 63 6b 72 65 66 29 3b 0d |, try_ba|ckref);.|
|00004e00| 09 20 20 2a 73 20 3d 20 | 73 61 76 65 3b 0d 0d 09 |. *s = |save;...|
|00004e10| 20 20 69 66 20 28 6d 61 | 74 63 68 20 21 3d 20 4e | if (ma|tch != N|
|00004e20| 55 4c 4c 29 0d 09 20 20 | 20 20 72 65 74 75 72 6e |ULL).. | return|
|00004e30| 28 28 63 68 61 72 20 2a | 29 20 6d 61 74 63 68 29 |((char *|) match)|
|00004e40| 3b 0d 09 20 20 65 6c 73 | 65 0d 09 20 20 20 20 7b |;.. els|e.. {|
|00004e50| 0d 09 20 20 20 20 20 20 | 73 74 61 72 74 20 3d 20 |.. |start = |
|00004e60| 73 3b 0d 09 20 20 20 20 | 20 20 6c 65 6e 20 3d 20 |s;.. | len = |
|00004e70| 65 6e 64 20 2d 20 73 74 | 61 72 74 3b 0d 09 20 20 |end - st|art;.. |
|00004e80| 20 20 7d 0d 09 7d 0d 20 | 20 20 20 20 20 72 65 74 | }..}. | ret|
|00004e90| 75 72 6e 28 4e 55 4c 4c | 29 3b 0d 20 20 20 20 7d |urn(NULL|);. }|
|00004ea0| 0d 7d 0d 0d 23 69 6e 63 | 6c 75 64 65 20 3c 63 74 |.}..#inc|lude <ct|
|00004eb0| 79 70 65 2e 68 3e 0d 69 | 6e 74 09 09 64 65 6c 74 |ype.h>.i|nt..delt|
|00004ec0| 61 30 5b 32 35 36 5d 3b | 0d 75 6e 73 69 67 6e 65 |a0[256];|.unsigne|
|00004ed0| 64 20 63 68 61 72 20 20 | 20 63 6d 61 70 5b 32 35 |d char | cmap[25|
|00004ee0| 36 5d 3b 09 09 2f 2a 20 | 28 75 6e 29 66 6f 6c 64 |6];../* |(un)fold|
|00004ef0| 65 64 20 63 68 61 72 61 | 63 74 65 72 73 20 2a 2f |ed chara|cters */|
|00004f00| 0d 75 6e 73 69 67 6e 65 | 64 20 63 68 61 72 09 70 |.unsigne|d char.p|
|00004f10| 61 74 74 65 72 6e 5b 35 | 30 30 30 5d 3b 0d 69 6e |attern[5|000];.in|
|00004f20| 74 09 09 70 61 74 6c 65 | 6e 3b 0d 0d 63 68 61 72 |t..patle|n;..char|
|00004f30| 20 2a 0d 62 6d 67 5f 73 | 65 61 72 63 68 28 62 75 | *.bmg_s|earch(bu|
|00004f40| 66 66 65 72 2c 20 62 75 | 66 6c 65 6e 29 0d 20 20 |ffer, bu|flen). |
|00004f50| 75 6e 73 69 67 6e 65 64 | 20 63 68 61 72 20 2a 62 |unsigned| char *b|
|00004f60| 75 66 66 65 72 3b 0d 20 | 20 69 6e 74 20 62 75 66 |uffer;. | int buf|
|00004f70| 6c 65 6e 3b 0d 7b 0d 20 | 20 72 65 67 69 73 74 65 |len;.{. | registe|
|00004f80| 72 20 75 6e 73 69 67 6e | 65 64 20 63 68 61 72 20 |r unsign|ed char |
|00004f90| 2a 6b 2c 20 2a 73 74 72 | 65 6e 64 2c 20 2a 73 2c |*k, *str|end, *s,|
|00004fa0| 20 2a 62 75 66 6c 69 6d | 3b 0d 20 20 72 65 67 69 | *buflim|;. regi|
|00004fb0| 73 74 65 72 20 69 6e 74 | 20 74 3b 0d 20 20 69 6e |ster int| t;. in|
|00004fc0| 74 20 6a 3b 0d 0d 20 20 | 69 66 20 28 70 61 74 6c |t j;.. |if (patl|
|00004fd0| 65 6e 20 3e 20 62 75 66 | 6c 65 6e 29 0d 20 20 20 |en > buf|len). |
|00004fe0| 20 72 65 74 75 72 6e 20 | 4e 55 4c 4c 3b 0d 0d 20 | return |NULL;.. |
|00004ff0| 20 62 75 66 6c 69 6d 20 | 3d 20 62 75 66 66 65 72 | buflim |= buffer|
|00005000| 20 2b 20 62 75 66 6c 65 | 6e 3b 0d 20 20 69 66 20 | + bufle|n;. if |
|00005010| 28 62 75 66 6c 65 6e 20 | 3e 20 70 61 74 6c 65 6e |(buflen |> patlen|
|00005020| 20 2a 20 34 29 0d 20 20 | 20 20 73 74 72 65 6e 64 | * 4). | strend|
|00005030| 20 3d 20 62 75 66 6c 69 | 6d 20 2d 20 70 61 74 6c | = bufli|m - patl|
|00005040| 65 6e 20 2a 20 34 3b 0d | 20 20 65 6c 73 65 0d 20 |en * 4;.| else. |
|00005050| 20 20 20 73 74 72 65 6e | 64 20 3d 20 62 75 66 66 | stren|d = buff|
|00005060| 65 72 3b 0d 0d 20 20 73 | 20 3d 20 62 75 66 66 65 |er;.. s| = buffe|
|00005070| 72 3b 0d 20 20 6b 20 3d | 20 62 75 66 66 65 72 20 |r;. k =| buffer |
|00005080| 2b 20 70 61 74 6c 65 6e | 20 2d 20 31 3b 0d 0d 20 |+ patlen| - 1;.. |
|00005090| 20 66 6f 72 20 28 3b 3b | 29 0d 20 20 20 20 7b 0d | for (;;|). {.|
|000050a0| 20 20 20 20 20 20 2f 2a | 20 54 68 65 20 64 72 65 | /*| The dre|
|000050b0| 61 64 65 64 20 69 6e 6e | 65 72 20 6c 6f 6f 70 2c |aded inn|er loop,|
|000050c0| 20 72 65 76 69 73 69 74 | 65 64 2e 20 2a 2f 0d 20 | revisit|ed. */. |
|000050d0| 20 20 20 20 20 77 68 69 | 6c 65 20 28 6b 20 3c 20 | whi|le (k < |
|000050e0| 73 74 72 65 6e 64 20 26 | 26 20 28 74 20 3d 20 64 |strend &|& (t = d|
|000050f0| 65 6c 74 61 30 5b 2a 6b | 5d 29 29 0d 09 7b 0d 09 |elta0[*k|]))..{..|
|00005100| 20 20 6b 20 2b 3d 20 74 | 3b 0d 09 20 20 6b 20 2b | k += t|;.. k +|
|00005110| 3d 20 64 65 6c 74 61 30 | 5b 2a 6b 5d 3b 0d 09 20 |= delta0|[*k];.. |
|00005120| 20 6b 20 2b 3d 20 64 65 | 6c 74 61 30 5b 2a 6b 5d | k += de|lta0[*k]|
|00005130| 3b 0d 09 7d 0d 20 20 20 | 20 20 20 77 68 69 6c 65 |;..}. | while|
|00005140| 20 28 6b 20 3c 20 62 75 | 66 6c 69 6d 20 26 26 20 | (k < bu|flim && |
|00005150| 64 65 6c 74 61 30 5b 2a | 6b 5d 29 0d 09 2b 2b 6b |delta0[*|k])..++k|
|00005160| 3b 0d 20 20 20 20 20 20 | 69 66 20 28 6b 20 3d 3d |;. |if (k ==|
|00005170| 20 62 75 66 6c 69 6d 29 | 0d 09 62 72 65 61 6b 3b | buflim)|..break;|
|00005180| 0d 20 20 20 20 0d 20 20 | 20 20 20 20 6a 20 3d 20 |. . | j = |
|00005190| 70 61 74 6c 65 6e 20 2d | 20 31 3b 0d 20 20 20 20 |patlen -| 1;. |
|000051a0| 20 20 73 20 3d 20 6b 3b | 0d 20 20 20 20 20 20 77 | s = k;|. w|
|000051b0| 68 69 6c 65 20 28 2d 2d | 6a 20 3e 3d 20 30 20 26 |hile (--|j >= 0 &|
|000051c0| 26 20 63 6d 61 70 5b 2a | 2d 2d 73 5d 20 3d 3d 20 |& cmap[*|--s] == |
|000051d0| 70 61 74 74 65 72 6e 5b | 6a 5d 29 0d 09 3b 0d 20 |pattern[|j])..;. |
|000051e0| 20 20 20 20 20 2f 2a 20 | 0d 09 64 65 6c 74 61 2d | /* |..delta-|
|000051f0| 6c 65 73 73 20 73 68 6f | 72 74 63 75 74 20 66 6f |less sho|rtcut fo|
|00005200| 72 20 6c 69 74 65 72 61 | 74 69 2c 20 62 75 74 20 |r litera|ti, but |
|00005210| 0d 09 73 68 6f 72 74 20 | 73 68 72 69 66 74 20 66 |..short |shrift f|
|00005220| 6f 72 20 67 65 6e 65 74 | 69 63 20 65 6e 67 69 6e |or genet|ic engin|
|00005230| 65 65 72 73 2e 0d 20 20 | 20 20 20 20 2a 2f 0d 20 |eers.. | */. |
|00005240| 20 20 20 20 20 69 66 20 | 28 6a 20 3e 3d 20 30 29 | if |(j >= 0)|
|00005250| 0d 09 6b 2b 2b 3b 0d 20 | 20 20 20 20 20 65 6c 73 |..k++;. | els|
|00005260| 65 20 09 09 2f 2a 20 73 | 75 62 6d 61 74 63 68 20 |e ../* s|ubmatch |
|00005270| 2a 2f 0d 09 72 65 74 75 | 72 6e 20 28 28 63 68 61 |*/..retu|rn ((cha|
|00005280| 72 20 2a 29 6b 29 3b 0d | 20 20 20 20 7d 0d 20 20 |r *)k);.| }. |
|00005290| 72 65 74 75 72 6e 28 4e | 55 4c 4c 29 3b 0d 7d 0d |return(N|ULL);.}.|
|000052a0| 0d 62 6d 67 5f 73 65 74 | 75 70 28 70 61 74 2c 20 |.bmg_set|up(pat, |
|000052b0| 66 6f 6c 64 65 64 29 09 | 09 09 2f 2a 20 63 6f 6d |folded).|../* com|
|000052c0| 70 75 74 65 20 22 62 6f | 79 65 72 2d 6d 6f 6f 72 |pute "bo|yer-moor|
|000052d0| 65 22 20 64 65 6c 74 61 | 20 74 61 62 6c 65 20 2a |e" delta| table *|
|000052e0| 2f 0d 20 20 63 68 61 72 | 20 2a 70 61 74 3b 0d 20 |/. char| *pat;. |
|000052f0| 20 69 6e 74 20 66 6f 6c | 64 65 64 3b 0d 7b 09 09 | int fol|ded;.{..|
|00005300| 09 09 09 2f 2a 20 2e 2e | 2e 20 48 41 4b 4d 45 4d |.../* ..|. HAKMEM|
|00005310| 20 6c 69 76 65 73 20 2e | 2e 2e 20 2a 2f 0d 20 20 | lives .|.. */. |
|00005320| 69 6e 74 20 6a 3b 0d 0d | 20 20 70 61 74 6c 65 6e |int j;..| patlen|
|00005330| 20 3d 20 73 74 72 6c 65 | 6e 28 70 61 74 29 3b 0d | = strle|n(pat);.|
|00005340| 0d 20 20 69 66 20 28 66 | 6f 6c 64 65 64 29 20 09 |. if (f|olded) .|
|00005350| 09 09 09 2f 2a 20 66 6f | 6c 64 20 63 61 73 65 20 |.../* fo|ld case |
|00005360| 77 68 69 6c 65 20 73 61 | 76 69 6e 67 20 70 61 74 |while sa|ving pat|
|00005370| 74 65 72 6e 20 2a 2f 0d | 20 20 20 20 66 6f 72 20 |tern */.| for |
|00005380| 28 6a 20 3d 20 30 3b 20 | 6a 20 3c 20 70 61 74 6c |(j = 0; |j < patl|
|00005390| 65 6e 3b 20 6a 2b 2b 29 | 20 0d 20 20 20 20 20 20 |en; j++)| . |
|000053a0| 70 61 74 74 65 72 6e 5b | 6a 5d 20 3d 20 28 69 73 |pattern[|j] = (is|
|000053b0| 75 70 70 65 72 28 28 69 | 6e 74 29 20 70 61 74 5b |upper((i|nt) pat[|
|000053c0| 6a 5d 29 20 3f 0d 09 28 | 63 68 61 72 29 20 74 6f |j]) ?..(|char) to|
|000053d0| 6c 6f 77 65 72 28 28 69 | 6e 74 29 20 70 61 74 5b |lower((i|nt) pat[|
|000053e0| 6a 5d 29 20 3a 20 70 61 | 74 5b 6a 5d 29 3b 0d 20 |j]) : pa|t[j]);. |
|000053f0| 20 65 6c 73 65 0d 20 20 | 20 20 20 20 6d 65 6d 63 | else. | memc|
|00005400| 70 79 28 70 61 74 74 65 | 72 6e 2c 20 70 61 74 2c |py(patte|rn, pat,|
|00005410| 20 70 61 74 6c 65 6e 29 | 3b 0d 0d 20 20 66 6f 72 | patlen)|;.. for|
|00005420| 20 28 6a 20 3d 20 30 3b | 20 6a 20 3c 20 32 35 36 | (j = 0;| j < 256|
|00005430| 3b 20 6a 2b 2b 29 0d 20 | 20 20 20 7b 0d 20 20 20 |; j++). | {. |
|00005440| 20 20 20 64 65 6c 74 61 | 30 5b 6a 5d 20 3d 20 70 | delta|0[j] = p|
|00005450| 61 74 6c 65 6e 3b 0d 20 | 20 20 20 20 20 63 6d 61 |atlen;. | cma|
|00005460| 70 5b 6a 5d 20 3d 20 28 | 63 68 61 72 29 20 6a 3b |p[j] = (|char) j;|
|00005470| 09 09 2f 2a 20 63 6f 75 | 6c 64 20 62 65 20 64 6f |../* cou|ld be do|
|00005480| 6e 65 20 61 74 20 63 6f | 6d 70 69 6c 65 20 74 69 |ne at co|mpile ti|
|00005490| 6d 65 20 2a 2f 0d 20 20 | 20 20 7d 0d 20 20 66 6f |me */. | }. fo|
|000054a0| 72 20 28 6a 20 3d 20 30 | 3b 20 6a 20 3c 20 70 61 |r (j = 0|; j < pa|
|000054b0| 74 6c 65 6e 20 2d 20 31 | 3b 20 6a 2b 2b 29 0d 20 |tlen - 1|; j++). |
|000054c0| 20 20 20 64 65 6c 74 61 | 30 5b 70 61 74 74 65 72 | delta|0[patter|
|000054d0| 6e 5b 6a 5d 5d 20 3d 20 | 70 61 74 6c 65 6e 20 2d |n[j]] = |patlen -|
|000054e0| 20 6a 20 2d 20 31 3b 0d | 20 20 64 65 6c 74 61 30 | j - 1;.| delta0|
|000054f0| 5b 70 61 74 74 65 72 6e | 5b 70 61 74 6c 65 6e 20 |[pattern|[patlen |
|00005500| 2d 20 31 5d 5d 20 3d 20 | 30 3b 0d 0d 20 20 69 66 |- 1]] = |0;.. if|
|00005510| 20 28 66 6f 6c 64 65 64 | 29 0d 20 20 20 20 7b 0d | (folded|). {.|
|00005520| 20 20 20 20 20 20 66 6f | 72 20 28 6a 20 3d 20 30 | fo|r (j = 0|
|00005530| 3b 20 6a 20 3c 20 70 61 | 74 6c 65 6e 20 2d 20 31 |; j < pa|tlen - 1|
|00005540| 3b 20 6a 2b 2b 29 0d 09 | 69 66 20 28 69 73 6c 6f |; j++)..|if (islo|
|00005550| 77 65 72 28 28 69 6e 74 | 29 20 70 61 74 74 65 72 |wer((int|) patter|
|00005560| 6e 5b 6a 5d 29 29 0d 09 | 20 20 64 65 6c 74 61 30 |n[j]))..| delta0|
|00005570| 5b 74 6f 75 70 70 65 72 | 28 28 69 6e 74 29 20 70 |[toupper|((int) p|
|00005580| 61 74 74 65 72 6e 5b 6a | 5d 29 5d 20 3d 20 70 61 |attern[j|])] = pa|
|00005590| 74 6c 65 6e 20 2d 20 6a | 20 2d 20 31 3b 0d 09 69 |tlen - j| - 1;..i|
|000055a0| 66 20 28 69 73 6c 6f 77 | 65 72 28 28 69 6e 74 29 |f (islow|er((int)|
|000055b0| 20 70 61 74 74 65 72 6e | 5b 70 61 74 6c 65 6e 20 | pattern|[patlen |
|000055c0| 2d 20 31 5d 29 29 0d 09 | 20 20 64 65 6c 74 61 30 |- 1]))..| delta0|
|000055d0| 5b 74 6f 75 70 70 65 72 | 28 28 69 6e 74 29 20 70 |[toupper|((int) p|
|000055e0| 61 74 74 65 72 6e 5b 70 | 61 74 6c 65 6e 20 2d 20 |attern[p|atlen - |
|000055f0| 31 5d 29 5d 20 3d 20 30 | 3b 0d 20 20 20 20 20 20 |1])] = 0|;. |
|00005600| 66 6f 72 20 28 6a 20 3d | 20 27 41 27 3b 20 6a 20 |for (j =| 'A'; j |
|00005610| 3c 3d 20 27 5a 27 3b 20 | 6a 2b 2b 29 0d 09 63 6d |<= 'Z'; |j++)..cm|
|00005620| 61 70 5b 6a 5d 20 3d 20 | 28 63 68 61 72 29 20 74 |ap[j] = |(char) t|
|00005630| 6f 6c 6f 77 65 72 28 28 | 69 6e 74 29 20 6a 29 3b |olower((|int) j);|
|00005640| 0d 20 20 20 20 7d 0d 7d | 0d 0d 0d 23 69 6e 63 6c |. }.}|...#incl|
|00005650| 75 64 65 20 3c 73 74 64 | 61 72 67 2e 68 3e 0d 23 |ude <std|arg.h>.#|
|00005660| 69 6e 63 6c 75 64 65 20 | 3c 63 74 79 70 65 2e 68 |include |<ctype.h|
|00005670| 3e 0d 23 69 6e 63 6c 75 | 64 65 20 3c 6d 65 6d 6f |>.#inclu|de <memo|
|00005680| 72 79 2e 68 3e 0d 23 69 | 6e 63 6c 75 64 65 20 3c |ry.h>.#i|nclude <|
|00005690| 4d 65 6e 75 73 2e 68 3e | 0d 23 69 6e 63 6c 75 64 |Menus.h>|.#includ|
|000056a0| 65 20 3c 53 79 73 45 71 | 75 2e 68 3e 0d 23 69 6e |e <SysEq|u.h>.#in|
|000056b0| 63 6c 75 64 65 20 3c 70 | 61 73 63 61 6c 2e 68 3e |clude <p|ascal.h>|
|000056c0| 0d 23 69 6e 63 6c 75 64 | 65 20 3c 44 69 61 6c 6f |.#includ|e <Dialo|
|000056d0| 67 73 2e 68 3e 0d 23 69 | 6e 63 6c 75 64 65 20 3c |gs.h>.#i|nclude <|
|000056e0| 4d 65 6e 75 73 2e 68 3e | 0d 23 69 6e 63 6c 75 64 |Menus.h>|.#includ|
|000056f0| 65 20 3c 4f 53 55 74 69 | 6c 73 2e 68 3e 0d 23 69 |e <OSUti|ls.h>.#i|
|00005700| 6e 63 6c 75 64 65 20 3c | 53 74 61 6e 64 61 72 64 |nclude <|Standard|
|00005710| 46 69 6c 65 2e 68 3e 0d | 23 69 6e 63 6c 75 64 65 |File.h>.|#include|
|00005720| 20 22 54 72 61 6e 73 53 | 6b 65 6c 2e 68 22 0d 23 | "TransS|kel.h".#|
|00005730| 69 6e 63 6c 75 64 65 20 | 22 54 72 61 6e 73 44 69 |include |"TransDi|
|00005740| 73 70 6c 61 79 2e 68 22 | 0d 23 69 6e 63 6c 75 64 |splay.h"|.#includ|
|00005750| 65 20 22 67 66 66 2e 68 | 22 0d 0d 65 78 74 65 72 |e "gff.h|"..exter|
|00005760| 6e 20 76 6f 69 64 20 2a | 61 6c 6c 6f 63 61 28 29 |n void *|alloca()|
|00005770| 3b 0d 0d 23 64 65 66 69 | 6e 65 20 46 69 6c 65 4d |;..#defi|ne FileM|
|00005780| 65 6e 75 49 44 20 35 30 | 30 0d 23 64 65 66 69 6e |enuID 50|0.#defin|
|00005790| 65 20 4c 53 54 57 49 4e | 44 20 35 30 30 0d 23 64 |e LSTWIN|D 500.#d|
|000057a0| 65 66 69 6e 65 20 41 62 | 6f 75 74 49 44 20 35 30 |efine Ab|outID 50|
|000057b0| 30 0d 23 64 65 66 69 6e | 65 20 4d 65 73 73 61 67 |0.#defin|e Messag|
|000057c0| 65 49 44 20 35 30 32 0d | 23 64 65 66 69 6e 65 20 |eID 502.|#define |
|000057d0| 41 52 47 44 4c 4f 47 20 | 35 30 33 0d 23 64 65 66 |ARGDLOG |503.#def|
|000057e0| 69 6e 65 20 48 45 4c 50 | 49 44 20 35 30 34 0d 23 |ine HELP|ID 504.#|
|000057f0| 64 65 66 69 6e 65 20 50 | 46 6f 6c 64 65 72 49 44 |define P|FolderID|
|00005800| 20 32 30 30 0d 23 64 65 | 66 69 6e 65 20 45 72 72 | 200.#de|fine Err|
|00005810| 6f 72 49 44 20 35 30 31 | 0d 23 64 65 66 69 6e 65 |orID 501|.#define|
|00005820| 20 41 52 47 53 45 41 52 | 43 48 20 31 0d 23 64 65 | ARGSEAR|CH 1.#de|
|00005830| 66 69 6e 65 20 41 52 47 | 43 41 4e 43 45 4c 20 32 |fine ARG|CANCEL 2|
|00005840| 0d 23 64 65 66 69 6e 65 | 20 41 52 47 50 46 4f 4c |.#define| ARGPFOL|
|00005850| 44 45 52 20 33 0d 23 64 | 65 66 69 6e 65 20 41 52 |DER 3.#d|efine AR|
|00005860| 47 50 46 49 4c 45 20 34 | 0d 23 64 65 66 69 6e 65 |GPFILE 4|.#define|
|00005870| 20 41 52 47 48 45 4c 50 | 20 35 0d 23 64 65 66 69 | ARGHELP| 5.#defi|
|00005880| 6e 65 20 41 52 47 52 45 | 47 45 58 50 20 38 0d 23 |ne ARGRE|GEXP 8.#|
|00005890| 64 65 66 69 6e 65 20 41 | 52 47 46 49 4c 45 50 41 |define A|RGFILEPA|
|000058a0| 54 20 39 0d 23 64 65 66 | 69 6e 65 20 41 52 47 53 |T 9.#def|ine ARGS|
|000058b0| 48 4f 57 46 4e 41 4d 45 | 20 31 30 0d 23 64 65 66 |HOWFNAME| 10.#def|
|000058c0| 69 6e 65 20 41 52 47 49 | 47 4e 43 41 53 45 20 31 |ine ARGI|GNCASE 1|
|000058d0| 31 0d 23 64 65 66 69 6e | 65 20 41 52 47 4f 4e 4c |1.#defin|e ARGONL|
|000058e0| 59 46 4e 41 4d 45 20 31 | 32 0d 23 64 65 66 69 6e |YFNAME 1|2.#defin|
|000058f0| 65 20 41 52 47 53 48 4f | 57 4c 4e 55 4d 20 31 33 |e ARGSHO|WLNUM 13|
|00005900| 0d 23 64 65 66 69 6e 65 | 20 41 52 47 53 48 53 45 |.#define| ARGSHSE|
|00005910| 41 52 43 48 20 31 34 0d | 23 64 65 66 69 6e 65 20 |ARCH 14.|#define |
|00005920| 41 52 47 4e 4f 4e 4d 41 | 54 43 48 20 31 35 0d 23 |ARGNONMA|TCH 15.#|
|00005930| 64 65 66 69 6e 65 20 41 | 52 47 54 52 41 49 4c 43 |define A|RGTRAILC|
|00005940| 4f 4e 54 20 31 36 0d 23 | 64 65 66 69 6e 65 20 41 |ONT 16.#|define A|
|00005950| 52 47 4c 45 41 44 43 4f | 4e 54 20 31 38 0d 23 64 |RGLEADCO|NT 18.#d|
|00005960| 65 66 69 6e 65 20 41 52 | 47 53 48 4f 57 42 59 54 |efine AR|GSHOWBYT|
|00005970| 45 20 32 30 0d 23 64 65 | 66 69 6e 65 20 41 52 47 |E 20.#de|fine ARG|
|00005980| 43 4f 55 4e 54 20 32 31 | 0d 23 64 65 66 69 6e 65 |COUNT 21|.#define|
|00005990| 20 41 52 47 57 48 57 4f | 52 44 20 32 32 0d 23 64 | ARGWHWO|RD 22.#d|
|000059a0| 65 66 69 6e 65 20 41 52 | 47 57 48 4c 49 4e 45 20 |efine AR|GWHLINE |
|000059b0| 32 33 0d 23 64 65 66 69 | 6e 65 20 41 52 47 4f 55 |23.#defi|ne ARGOU|
|000059c0| 54 46 49 4c 45 20 32 34 | 0d 0d 23 64 65 66 69 6e |TFILE 24|..#defin|
|000059d0| 65 20 4f 4e 20 31 0d 23 | 64 65 66 69 6e 65 20 4f |e ON 1.#|define O|
|000059e0| 46 46 20 30 0d 0d 73 74 | 61 74 69 63 20 57 69 6e |FF 0..st|atic Win|
|000059f0| 64 6f 77 50 74 72 09 74 | 68 65 57 69 6e 64 6f 77 |dowPtr.t|heWindow|
|00005a00| 3b 0d 73 74 61 74 69 63 | 20 73 68 6f 72 74 20 41 |;.static| short A|
|00005a10| 6c 6c 44 6f 6e 65 20 3d | 20 66 61 6c 73 65 3b 0d |llDone =| false;.|
|00005a20| 73 74 61 74 69 63 20 44 | 69 61 6c 6f 67 50 74 72 |static D|ialogPtr|
|00005a30| 20 41 72 67 44 69 61 6c | 6f 67 3b 0d 73 74 61 74 | ArgDial|og;.stat|
|00005a40| 69 63 20 69 6e 74 20 61 | 72 67 63 3b 0d 73 74 61 |ic int a|rgc;.sta|
|00005a50| 74 69 63 20 63 68 61 72 | 20 2a 2a 61 72 67 76 3b |tic char| **argv;|
|00005a60| 0d 73 74 61 74 69 63 20 | 69 6e 74 20 69 67 6e 6f |.static |int igno|
|00005a70| 72 65 5f 63 61 73 65 20 | 3d 20 31 3b 09 09 2f 2a |re_case |= 1;../*|
|00005a80| 20 43 6f 6d 70 69 6c 65 | 20 74 68 65 20 72 65 67 | Compile| the reg|
|00005a90| 65 78 70 20 74 6f 20 69 | 67 6e 6f 72 65 20 63 61 |exp to i|gnore ca|
|00005aa0| 73 65 2e 20 2a 2f 0d 73 | 74 61 74 69 63 20 63 68 |se. */.s|tatic ch|
|00005ab0| 61 72 20 72 65 67 65 78 | 70 5f 62 75 66 5b 32 35 |ar regex|p_buf[25|
|00005ac0| 36 5d 3b 09 09 2f 2a 20 | 54 68 65 20 72 65 67 75 |6];../* |The regu|
|00005ad0| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 2e 20 |lar expr|ession. |
|00005ae0| 2a 2f 0d 73 74 61 74 69 | 63 20 69 6e 74 20 72 65 |*/.stati|c int re|
|00005af0| 67 65 78 70 5f 6c 65 6e | 3b 09 09 20 20 20 20 2f |gexp_len|;.. /|
|00005b00| 2a 20 4c 65 6e 67 74 68 | 20 6f 66 20 74 68 65 20 |* Length| of the |
|00005b10| 72 65 67 75 6c 61 72 20 | 65 78 70 72 65 73 73 69 |regular |expressi|
|00005b20| 6f 6e 2e 20 2a 2f 0d 73 | 74 61 74 69 63 20 69 6e |on. */.s|tatic in|
|00005b30| 74 20 63 6f 75 6e 74 5f | 6c 69 6e 65 73 20 3d 20 |t count_|lines = |
|00005b40| 30 3b 09 09 2f 2a 20 53 | 68 6f 77 20 6f 6e 6c 79 |0;../* S|how only|
|00005b50| 20 63 6f 75 6e 74 20 6f | 66 20 6d 61 74 63 68 69 | count o|f matchi|
|00005b60| 6e 67 20 6c 69 6e 65 73 | 2e 20 2a 2f 0d 73 74 61 |ng lines|. */.sta|
|00005b70| 74 69 63 20 69 6e 74 20 | 6c 69 73 74 5f 66 69 6c |tic int |list_fil|
|00005b80| 65 73 20 3d 20 30 3b 09 | 09 2f 2a 20 53 68 6f 77 |es = 0;.|./* Show|
|00005b90| 20 6f 6e 6c 79 20 6e 61 | 6d 65 73 20 6f 66 20 6d | only na|mes of m|
|00005ba0| 61 74 63 68 69 6e 67 20 | 66 69 6c 65 73 2e 20 2a |atching |files. *|
|00005bb0| 2f 0d 73 74 61 74 69 63 | 20 69 6e 74 20 77 68 6f |/.static| int who|
|00005bc0| 6c 65 5f 77 6f 72 64 20 | 3d 20 30 3b 09 09 2f 2a |le_word |= 0;../*|
|00005bd0| 20 72 65 67 65 78 70 20 | 6d 75 63 68 20 6d 61 74 | regexp |much mat|
|00005be0| 63 68 20 61 20 77 6f 72 | 64 20 6f 6e 6c 79 2e 20 |ch a wor|d only. |
|00005bf0| 2a 2f 0d 73 74 61 74 69 | 63 20 69 6e 74 20 77 68 |*/.stati|c int wh|
|00005c00| 6f 6c 65 5f 6c 69 6e 65 | 20 3d 20 30 3b 09 09 2f |ole_line| = 0;../|
|00005c10| 2a 20 6d 61 74 63 68 69 | 6e 67 20 6f 6e 6c 79 20 |* matchi|ng only |
|00005c20| 77 68 6f 6c 65 20 6c 69 | 6e 65 73 2e 20 2a 2f 0d |whole li|nes. */.|
|00005c30| 73 74 61 74 69 63 20 69 | 6e 74 20 6c 69 6e 65 5f |static i|nt line_|
|00005c40| 63 6f 75 6e 74 20 3d 20 | 30 3b 09 09 2f 2a 20 43 |count = |0;../* C|
|00005c50| 6f 75 6e 74 20 6f 66 20 | 6d 61 74 63 68 69 6e 67 |ount of |matching|
|00005c60| 20 6c 69 6e 65 73 20 66 | 6f 72 20 61 20 66 69 6c | lines f|or a fil|
|00005c70| 65 2e 20 2a 2f 0d 73 74 | 61 74 69 63 20 69 6e 74 |e. */.st|atic int|
|00005c80| 20 75 73 65 5f 6f 75 74 | 66 69 6c 65 20 3d 20 30 | use_out|file = 0|
|00005c90| 3b 20 20 20 20 20 2f 2a | 20 4f 75 74 70 75 74 20 |; /*| Output |
|00005ca0| 74 6f 20 66 69 6c 65 20 | 2a 2f 0d 73 74 61 74 69 |to file |*/.stati|
|00005cb0| 63 20 53 46 52 65 70 6c | 79 20 74 6d 70 46 69 6c |c SFRepl|y tmpFil|
|00005cc0| 65 3b 0d 73 74 61 74 69 | 63 20 69 6e 74 20 53 68 |e;.stati|c int Sh|
|00005cd0| 6f 77 53 65 61 72 63 68 | 65 64 46 69 6c 65 73 20 |owSearch|edFiles |
|00005ce0| 3d 20 30 3b 20 20 2f 2a | 20 44 69 73 70 6c 61 79 |= 0; /*| Display|
|00005cf0| 20 66 69 6c 65 73 20 73 | 65 61 72 63 68 65 64 20 | files s|earched |
|00005d00| 2a 2f 0d 73 74 61 74 69 | 63 20 63 68 61 72 20 66 |*/.stati|c char f|
|00005d10| 69 6c 65 5f 70 61 74 74 | 65 72 6e 5b 32 35 36 5d |ile_patt|ern[256]|
|00005d20| 3b 0d 73 74 61 74 69 63 | 20 63 68 61 72 20 74 72 |;.static| char tr|
|00005d30| 61 6e 73 6c 61 74 65 5b | 5f 4e 4f 54 43 48 41 52 |anslate[|_NOTCHAR|
|00005d40| 5d 3b 20 2f 2a 20 54 72 | 61 6e 73 6c 61 74 65 20 |]; /* Tr|anslate |
|00005d50| 74 61 62 6c 65 20 66 6f | 72 20 63 61 73 65 20 63 |table fo|r case c|
|00005d60| 6f 6e 76 65 72 73 69 6f | 6e 0d 09 09 09 09 20 20 |onversio|n..... |
|00005d70| 20 28 6e 65 65 64 65 64 | 20 62 79 20 74 68 65 20 | (needed| by the |
|00005d80| 62 61 63 6b 74 72 61 63 | 6b 69 6e 67 20 6d 61 74 |backtrac|king mat|
|00005d90| 63 68 65 72 29 2e 20 2a | 2f 0d 73 74 61 74 69 63 |cher). *|/.static|
|00005da0| 20 53 6b 65 6c 53 74 61 | 72 74 65 64 20 3d 20 66 | SkelSta|rted = f|
|00005db0| 61 6c 73 65 3b 0d 73 74 | 61 74 69 63 20 57 44 50 |alse;.st|atic WDP|
|00005dc0| 42 52 65 63 20 74 68 65 | 57 44 50 42 52 65 63 3b |BRec the|WDPBRec;|
|00005dd0| 09 09 09 20 20 20 0d 73 | 74 61 74 69 63 20 4b 65 |... .s|tatic Ke|
|00005de0| 79 4d 61 70 20 6b 6d 3b | 0d 73 74 61 74 69 63 20 |yMap km;|.static |
|00005df0| 69 6e 74 20 4f 75 74 46 | 69 6c 65 4f 70 65 6e 3b |int OutF|ileOpen;|
|00005e00| 0d 73 74 61 74 69 63 20 | 46 49 4c 45 20 2a 66 70 |.static |FILE *fp|
|00005e10| 3b 0d 0d 76 6f 69 64 20 | 43 68 65 63 6b 46 6f 72 |;..void |CheckFor|
|00005e20| 42 72 65 61 6b 28 20 76 | 6f 69 64 20 29 0d 7b 0d |Break( v|oid ).{.|
|00005e30| 20 20 20 69 6e 74 20 69 | 3b 0d 20 20 20 0d 20 20 | int i|;. . |
|00005e40| 20 47 65 74 4b 65 79 73 | 28 6b 6d 29 3b 0d 20 20 | GetKeys|(km);. |
|00005e50| 20 69 66 20 28 6b 6d 5b | 31 5d 20 3d 3d 20 38 34 | if (km[|1] == 84|
|00005e60| 32 31 33 37 36 4c 29 20 | 20 2f 2a 20 53 65 65 6d |21376L) | /* Seem|
|00005e70| 73 20 74 6f 20 62 65 20 | 66 61 6e 2d 70 65 72 69 |s to be |fan-peri|
|00005e80| 6f 64 20 2a 2f 0d 20 20 | 20 20 09 57 65 41 72 65 |od */. | .WeAre|
|00005e90| 53 74 6f 70 70 65 64 20 | 3d 20 74 72 75 65 3b 0d |Stopped |= true;.|
|00005ea0| 7d 0d 0d 0d 76 6f 69 64 | 20 41 62 45 6e 64 28 53 |}...void| AbEnd(S|
|00005eb0| 74 72 32 35 35 20 70 29 | 0d 7b 0d 20 20 20 50 61 |tr255 p)|.{. Pa|
|00005ec0| 72 61 6d 54 65 78 74 28 | 70 2c 20 22 5c 70 22 2c |ramText(|p, "\p",|
|00005ed0| 20 22 5c 70 22 2c 20 22 | 5c 70 22 29 3b 0d 20 20 | "\p", "|\p");. |
|00005ee0| 20 41 6c 65 72 74 28 45 | 72 72 6f 72 49 44 2c 20 | Alert(E|rrorID, |
|00005ef0| 30 4c 29 3b 0d 20 20 20 | 69 66 20 28 4f 75 74 46 |0L);. |if (OutF|
|00005f00| 69 6c 65 4f 70 65 6e 29 | 20 7b 0d 20 20 20 20 20 |ileOpen)| {. |
|00005f10| 20 20 20 20 66 63 6c 6f | 73 65 28 66 70 29 3b 0d | fclo|se(fp);.|
|00005f20| 20 20 20 20 20 20 20 20 | 20 4f 75 74 46 69 6c 65 | | OutFile|
|00005f30| 4f 70 65 6e 20 3d 20 66 | 61 6c 73 65 3b 0d 20 20 |Open = f|alse;. |
|00005f40| 20 7d 0d 20 20 20 2f 2a | 20 43 6c 6f 73 65 20 6f | }. /*| Close o|
|00005f50| 6c 64 20 57 44 20 69 66 | 20 6e 65 65 64 65 64 20 |ld WD if| needed |
|00005f60| 2a 2f 0d 20 20 20 69 66 | 20 28 74 68 65 57 44 50 |*/. if| (theWDP|
|00005f70| 42 52 65 63 2e 69 6f 57 | 44 50 72 6f 63 49 44 20 |BRec.ioW|DProcID |
|00005f80| 21 3d 20 30 29 20 50 42 | 43 6c 6f 73 65 57 44 28 |!= 0) PB|CloseWD(|
|00005f90| 26 74 68 65 57 44 50 42 | 52 65 63 2c 20 66 61 6c |&theWDPB|Rec, fal|
|00005fa0| 73 65 29 3b 0d 20 20 20 | 69 66 20 28 53 6b 65 6c |se);. |if (Skel|
|00005fb0| 53 74 61 72 74 65 64 29 | 20 7b 0d 20 20 20 20 20 |Started)| {. |
|00005fc0| 20 53 6b 65 6c 43 6c 6f | 62 62 65 72 28 29 3b 0d | SkelClo|bber();.|
|00005fd0| 20 20 20 20 20 20 53 6b | 65 6c 57 68 6f 61 28 29 | Sk|elWhoa()|
|00005fe0| 3b 0d 20 20 20 7d 0d 20 | 20 20 65 78 69 74 28 31 |;. }. | exit(1|
|00005ff0| 29 3b 0d 7d 0d 0d 0d 76 | 6f 69 64 20 4d 65 73 73 |);.}...v|oid Mess|
|00006000| 61 67 65 28 53 74 72 32 | 35 35 20 70 29 0d 7b 0d |age(Str2|55 p).{.|
|00006010| 20 20 20 50 61 72 61 6d | 54 65 78 74 28 70 2c 20 | Param|Text(p, |
|00006020| 22 5c 70 22 2c 20 22 5c | 70 22 2c 20 22 5c 70 22 |"\p", "\|p", "\p"|
|00006030| 29 3b 0d 20 20 20 41 6c | 65 72 74 28 4d 65 73 73 |);. Al|ert(Mess|
|00006040| 61 67 65 49 44 2c 20 30 | 4c 29 3b 0d 7d 0d 0d 73 |ageID, 0|L);.}..s|
|00006050| 74 61 74 69 63 20 76 6f | 69 64 20 53 65 74 41 72 |tatic vo|id SetAr|
|00006060| 67 49 74 65 6d 28 44 69 | 61 6c 6f 67 50 74 72 20 |gItem(Di|alogPtr |
|00006070| 41 72 67 44 69 61 6c 6f | 67 2c 20 73 68 6f 72 74 |ArgDialo|g, short|
|00006080| 20 69 74 65 6d 2c 20 73 | 68 6f 72 74 20 76 61 6c | item, s|hort val|
|00006090| 75 65 29 0d 7b 0d 20 20 | 20 73 68 6f 72 74 20 69 |ue).{. | short i|
|000060a0| 74 65 6d 54 79 70 65 3b | 0d 20 20 20 52 65 63 74 |temType;|. Rect|
|000060b0| 20 69 74 65 6d 52 65 63 | 74 3b 0d 20 20 20 48 61 | itemRec|t;. Ha|
|000060c0| 6e 64 6c 65 20 69 74 65 | 6d 48 61 6e 64 6c 65 3b |ndle ite|mHandle;|
|000060d0| 0d 20 20 20 0d 20 20 20 | 47 65 74 44 49 74 65 6d |. . |GetDItem|
|000060e0| 28 41 72 67 44 69 61 6c | 6f 67 2c 20 69 74 65 6d |(ArgDial|og, item|
|000060f0| 2c 20 26 69 74 65 6d 54 | 79 70 65 2c 20 26 69 74 |, &itemT|ype, &it|
|00006100| 65 6d 48 61 6e 64 6c 65 | 2c 20 26 69 74 65 6d 52 |emHandle|, &itemR|
|00006110| 65 63 74 29 3b 0d 20 20 | 20 53 65 74 43 74 6c 56 |ect);. | SetCtlV|
|00006120| 61 6c 75 65 28 28 43 6f | 6e 74 72 6f 6c 48 61 6e |alue((Co|ntrolHan|
|00006130| 64 6c 65 29 20 69 74 65 | 6d 48 61 6e 64 6c 65 2c |dle) ite|mHandle,|
|00006140| 20 76 61 6c 75 65 29 3b | 0d 7d 0d 0d 70 61 73 63 | value);|.}..pasc|
|00006150| 61 6c 20 42 6f 6f 6c 65 | 61 6e 20 46 6f 6c 64 65 |al Boole|an Folde|
|00006160| 72 73 4f 6e 6c 79 28 70 | 29 0d 09 50 61 72 6d 42 |rsOnly(p|)..ParmB|
|00006170| 6c 6b 50 74 72 20 70 3b | 0d 7b 0d 09 2f 2a 20 4e |lkPtr p;|.{../* N|
|00006180| 6f 72 6d 61 6c 6c 79 2c | 20 66 6f 6c 64 65 72 73 |ormally,| folders|
|00006190| 20 61 72 65 20 41 4c 57 | 41 59 53 20 73 68 6f 77 | are ALW|AYS show|
|000061a0| 6e 2c 20 61 6e 64 20 61 | 72 65 6e 27 74 20 65 76 |n, and a|ren't ev|
|000061b0| 65 6e 20 70 61 73 73 65 | 64 20 74 6f 09 09 2a 2f |en passe|d to..*/|
|000061c0| 0d 09 2f 2a 20 74 68 69 | 73 20 66 69 6c 65 20 66 |../* thi|s file f|
|000061d0| 69 6c 74 65 72 20 66 6f | 72 20 6a 75 64 67 65 6d |ilter fo|r judgem|
|000061e0| 65 6e 74 2e 20 55 6e 64 | 65 72 20 73 75 63 68 20 |ent. Und|er such |
|000061f0| 63 69 72 63 75 6d 73 74 | 61 6e 63 65 73 2c 20 69 |circumst|ances, i|
|00006200| 74 20 69 73 09 09 2a 2f | 0d 09 2f 2a 20 6f 6e 6c |t is..*/|../* onl|
|00006210| 79 20 6e 65 63 65 73 73 | 61 72 79 20 74 6f 20 62 |y necess|ary to b|
|00006220| 6c 69 6e 64 6c 79 20 72 | 65 74 75 72 6e 20 54 52 |lindly r|eturn TR|
|00006230| 55 45 20 28 61 6c 6c 6f | 77 20 6e 6f 20 66 69 6c |UE (allo|w no fil|
|00006240| 65 73 20 77 68 61 74 73 | 6f 65 76 65 72 29 2e 09 |es whats|oever)..|
|00006250| 2a 2f 0d 09 2f 2a 20 48 | 6f 77 65 76 65 72 2c 20 |*/../* H|owever, |
|00006260| 53 74 61 6e 64 61 72 64 | 20 46 69 6c 65 20 69 73 |Standard| File is|
|00006270| 20 6e 6f 74 20 64 6f 63 | 75 6d 65 6e 74 65 64 20 | not doc|umented |
|00006280| 69 6e 20 73 75 63 68 20 | 61 20 6d 61 6e 6e 65 72 |in such |a manner|
|00006290| 2c 20 61 6e 64 09 09 2a | 2f 0d 09 2f 2a 20 74 68 |, and..*|/../* th|
|000062a0| 69 73 20 66 65 61 74 75 | 72 65 20 6d 61 79 20 6e |is featu|re may n|
|000062b0| 6f 74 20 62 65 20 54 52 | 55 45 20 69 6e 20 74 68 |ot be TR|UE in th|
|000062c0| 65 20 66 75 74 75 72 65 | 2e 20 54 68 65 72 65 66 |e future|. Theref|
|000062d0| 6f 72 65 2c 20 77 65 20 | 44 4f 20 63 68 65 63 6b |ore, we |DO check|
|000062e0| 09 2a 2f 0d 09 2f 2a 20 | 74 6f 20 73 65 65 20 69 |.*/../* |to see i|
|000062f0| 66 20 74 68 65 20 65 6e | 74 72 79 20 70 61 73 73 |f the en|try pass|
|00006300| 65 64 20 74 6f 20 75 73 | 20 64 65 73 63 72 69 62 |ed to us| describ|
|00006310| 65 73 20 61 20 66 69 6c | 65 20 6f 72 20 61 20 64 |es a fil|e or a d|
|00006320| 69 72 65 63 74 6f 72 79 | 2e 09 2a 2f 0d 0d 09 69 |irectory|..*/...i|
|00006330| 66 20 28 28 70 2d 3e 66 | 69 6c 65 50 61 72 61 6d |f ((p->f|ileParam|
|00006340| 2e 69 6f 46 6c 41 74 74 | 72 69 62 20 26 20 30 78 |.ioFlAtt|rib & 0x|
|00006350| 31 30 29 20 21 3d 20 30 | 29 0d 09 09 72 65 74 75 |10) != 0|)...retu|
|00006360| 72 6e 28 66 61 6c 73 65 | 29 3b 0d 09 72 65 74 75 |rn(false|);..retu|
|00006370| 72 6e 28 74 72 75 65 29 | 3b 0d 7d 0d 0d 0d 73 74 |rn(true)|;.}...st|
|00006380| 61 74 69 63 20 69 6e 74 | 20 47 65 74 53 65 61 72 |atic int| GetSear|
|00006390| 63 68 46 6f 6c 64 65 72 | 28 76 6f 69 64 29 0d 7b |chFolder|(void).{|
|000063a0| 0d 20 20 20 20 53 46 52 | 65 70 6c 79 20 74 68 65 |. SFR|eply the|
|000063b0| 44 69 72 3b 0d 20 20 20 | 20 50 6f 69 6e 74 20 70 |Dir;. | Point p|
|000063c0| 3b 0d 20 20 20 20 63 68 | 61 72 20 2a 66 6e 61 6d |;. ch|ar *fnam|
|000063d0| 65 3b 0d 20 20 20 20 4f | 53 54 79 70 65 20 66 74 |e;. O|SType ft|
|000063e0| 79 70 65 20 3d 20 27 54 | 45 58 54 27 3b 20 20 2f |ype = 'T|EXT'; /|
|000063f0| 2a 20 56 61 6c 75 65 20 | 64 6f 65 73 20 6e 6f 74 |* Value |does not|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.